it does not work :
import QtQuick 2.4
import QtQuick.LocalStorage 2.0
Rectangle {
property alias mouseArea: mouseArea
//property string r1 :""
property variant r1: Array()
property int tedad
width: 360
height: 360
MouseArea {
id: mouseArea
anchors.fill: parent
}
function fdatabase() {
var db = LocalStorage.openDatabaseSync("ravandi", "1.0", "The Example QML SQL!", 1000000);
db.transaction(
function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS jadval(id integer primary key autoincrement not null,`name` varchar(40),`last` varchar(40))');
tx.executeSql("insert into jadval (name,last) values('mohammad','ravandi')");
var rs = tx.executeSql('SELECT * FROM jadval');
tedad = rs.rows.length;
for(var i = 0; i < rs.rows.length; i++) {
r1 +=rs.rows.item(i).name
}
//console.log(r1)
}
)
}
Component.onCompleted: fdatabase()
Column {
spacing: 5;
Repeater {
model: r1;
Rectangle {
width:100
height:30
border.color: "red"
border.width: 1
Text{
anchors.horizontalCenter: parent.horizontalCenter
//renderType: Text.NativeRendering
text:modelData
}
}
}
}
}
import QtQuick 2.4
import QtQuick.LocalStorage 2.0
Rectangle {
property alias mouseArea: mouseArea
//property string r1 :""
property variant r1: Array()
property int tedad
width: 360
height: 360
MouseArea {
id: mouseArea
anchors.fill: parent
}
function fdatabase() {
var db = LocalStorage.openDatabaseSync("ravandi", "1.0", "The Example QML SQL!", 1000000);
db.transaction(
function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS jadval(id integer primary key autoincrement not null,`name` varchar(40),`last` varchar(40))');
tx.executeSql("insert into jadval (name,last) values('mohammad','ravandi')");
var rs = tx.executeSql('SELECT * FROM jadval');
tedad = rs.rows.length;
for(var i = 0; i < rs.rows.length; i++) {
r1 +=rs.rows.item(i).name
}
//console.log(r1)
}
)
}
Component.onCompleted: fdatabase()
Column {
spacing: 5;
Repeater {
model: r1;
Rectangle {
width:100
height:30
border.color: "red"
border.width: 1
Text{
anchors.horizontalCenter: parent.horizontalCenter
//renderType: Text.NativeRendering
text:modelData
}
}
}
}
}
To copy to clipboard, switch view to plain text mode
I wrote , according to the code:
import QtQuick 2.0
Rectangle {
width:500
height:700
property variant r1:["ali", "ravandi", "sadegh"]
Column {
Repeater {
model: r1
Rectangle {
width:100
height:30
border.color: "red"
border.width: 1
Text { text: "Data: " + modelData }
}
}
}
}
import QtQuick 2.0
Rectangle {
width:500
height:700
property variant r1:["ali", "ravandi", "sadegh"]
Column {
Repeater {
model: r1
Rectangle {
width:100
height:30
border.color: "red"
border.width: 1
Text { text: "Data: " + modelData }
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks