Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

update ListView with onClicked

$
0
0
I’m using this to show contents of a database import "test.js" as Logic ....... ........... Text {      id: text1      x: 100      y: 100      text: qsTr(Logic.r)      opacity: 0      font.pixelSize: 12       }  ListView {     id: logic_rs      x: 455      y: -47      model: Logic.get_db(5,0)        delegate: Text{           text: qsTr(Logic.r)} }   What I would like to do is be able to update is list with the next 5 elements from the database Here is my failed attempt  onClicked:{                      Logic.index_count =  Logic.index_count+5                      logic_rs=Logic.index_count                                         } My main goal is: I have a (large) list of items only 5 at a time are shown, there are next and prev button which show the next 5 items or the prev 5 items. Here is my js for getting the data var index_count = 0 var up_check = 0  var r = "" function get_db(a, up_check) {    var db = LocalStorage.openDatabaseSync("DB5", "1.0", "The Example QML SQL!", 1000000);   db.transaction(     function(tx) {  /*  tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');         for ( var z=0; z<1000; z++){         tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'Movie', z ]);       }   */   var rs = tx.executeSql('SELECT * FROM Greeting');     r = ""        for(var i = 0; i < a; i++) {           if (i>index_count-1 && up_check ===0)              r += rs.rows.item(i).salutation + ": " + rs.rows.item(i).salutee + "\t\t"                 if (up_check === 1){                     var size_check =0                       if (i >index_count-11   && size_check !==9)  {                          r += rs.rows.item(i).salutation + ": " + rs.rows.item(i).salutee + "\t\t"                         size_check++                      }                 }             }                  console.log(r);        index_count=a;               })}

Viewing all articles
Browse latest Browse all 4972

Trending Articles