Qt Code:
  1. import QtQuick 2.4
  2. import QtQuick.LocalStorage 2.0
  3. Rectangle {
  4. property alias mouseArea: mouseArea
  5. //property variant r1: Array()
  6. property variant r1: []
  7. property int tedad
  8. width: 360
  9. height: 360
  10. MouseArea {
  11. id: mouseArea
  12. anchors.fill: parent
  13. }
  14. function fdatabase() {
  15. var db = LocalStorage.openDatabaseSync("ravandi", "1.0", "The Example QML SQL!", 1000000);
  16. db.transaction(
  17. function(tx) {
  18. tx.executeSql('CREATE TABLE IF NOT EXISTS jadval(id integer primary key autoincrement not null,`name` varchar(40),`last` varchar(40))');
  19. tx.executeSql("insert into jadval (name,last) values('ahmad','ravandi')");
  20. var rs = tx.executeSql('SELECT * FROM jadval');
  21. tedad = rs.rows.length;
  22. var items = [];
  23. for(var i = 0; i < rs.rows.length; i++) {
  24. items.push(rs.rows.item(i).name);
  25. r1 = items;
  26. print(r1)
  27. // r1 +=rs.rows.item(i).name
  28.  
  29. }
  30. }
  31. )
  32. }
  33. Component.onCompleted: fdatabase()
  34. Column {
  35. spacing: 5;
  36. Repeater {
  37. model: tedad;
  38. Rectangle {
  39. width:100
  40. height:30
  41. border.color: "red"
  42. border.width: 1
  43. Text{
  44. id:items
  45. anchors.horizontalCenter: parent.horizontalCenter
  46. renderType: Text.NativeRendering
  47. text: r1
  48. }
  49. }
  50. }
  51. }
  52. }
To copy to clipboard, switch view to plain text mode 

erorr:
2016/01/28 21:29:04 sqlite.qml.:47: file:///F:/workspace/sqlite.qml.:47:12: Unab
le to assign QJSValue to QString