Loading QML Elements to ListView from database -


i'm writing app n9 , have database problem. i'm not using main.cpp or other c++ file app. create,delete,add etc. data database using javscript within qml. right i'm putting out string entries. works fine. want show entries in database listview. how can that?

you can create model listview dynamically. these:

import qtquick 2.0 import "main.js" main  rectangle {     id: root      listview {          width: 180; height: 200           model: main.createmodel(root)          delegate: text {              text: name + ": " + number         }      } }     

and main.js

function createmodel(parent) {     var s = 'import qtquick 2.0; listmodel {\n';     var data = ["a", "b"];  // data database here     for(var x in data) {         var s2 = "listelement {name: \"" + x+ "\"; number: \"" + x + "\" }\n";         s += s2;     }      s += "}\n";     console.log(s);     return qt.createqmlobject(s, parent, "mainmodel"); } 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -