我有以下简单的sqlite db代码,用Qt编写(id
指的是根元素的Rectangle{
id:enterYourName
anchors.centerIn: nameContianer
color: "white"
width:0.395*windowid.width
height:0.227*windowid.height
function getDatabase() {
return LocalStorage.openDatabaseSync("HomeScreen", "1.0", "StorageDatabase", 100000);
}
function typetable() {
var db = getDatabase();
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS mycircletype (mytypee REAL)');
});
}
function setType(yvalue) {
var db = getDatabase();
db.transaction(function(tx) {
tx.executeSql('INSERT OR REPLACE INTO mycircletype VALUES (?);', [yvalue]);
}
);
}
function getType() {
var db = getDatabase();
var res="";
db.transaction(function(tx) {
var rs = tx.executeSql('SELECT mytypee FROM mycircletype');
if (rs.rows.length > 0) {
res = rs.rows.item(0).mytypee;
} else {
res = 0.506*windowid.height;
}
})
return res;
}
Component.onCompleted: {
enterYourName.typetable()
}
}
):
y
我还有一张图片,我希望保存Rectangle
值,还有三张Rectangle
s。单击这些y
中的任何一个时,图像的y
值将更改为特定值。我想保存该值,下次我的应用程序启动时,我希望该值为我的图像的起始// here is the image
Image{
id:tick1
source: "../../pics/tick.png"
width:0.0395*windowid.width
height:0.041*windowid.height
x: 0.4474*windowid.width
y: enterYourName.getType() //here the issue appears
visible: false
}
// here are the 3 rectangles
Rectangle{
id: op2op1
x:windowid.width+10
y:0.324*windowid.height
width:0.170*windowid.width
height:0.130*windowid.height
MouseArea{
anchors.fill: parent
onClicked: {
enterYourName.setType(0.370*windowid.height)
tick1.y = 0.370*windowid.height
tick1.visible = true
}
}
}
Rectangle{
id: op2op2
x:0.350*windowid.width
y:0.364*windowid.height
width:0.170*windowid.width
height:0.130*windowid.height
MouseArea{
anchors.fill: parent
onClicked: {
enterYourName.setType(0.231*windowid.height)
tick1.y = 0.231*windowid.height
tick1.visible = true
}
}
}
Rectangle{
id: op2op3
x:0.350*windowid.width
y:0.364*windowid.height
width:0.170*windowid.width
height:0.130*windowid.height
MouseArea{
anchors.fill: parent
onClicked: {
enterYourName.setType(0.506*windowid.height)
tick1.y = 0.506*windowid.height
tick1.visible = true
}
}
}
值。这是我的代码:
Unable to assign null to double
不幸的是,我收到一条错误,指出y
指向图片的y
值:
y:enterYourName.getType()
如何解决此问题,以便保存和检索图像的<div></div>
值而不会出现任何问题?