How do I populate the table with the sql data
Moved
Unsolved
QML and Qt Quick
-
Re: How do I retrieve locally stored sql file and parse it in json data format to an external url in QML?
Been goofing around with reading the sql data from the db but now I am stuck at populating the said data in a table view, any ideas or a workaround ?function readData() { var db = readData() db.transaction(function (tx) { var results = tx.executeSql('SELECT rowid, firstname, secondname, date_of_birth FROM UserDetails order by rowid desc') for (var i = 0; i < results.rows.length; i++) { listModel.append({ id:results.rows.item(i).rowid, checked:"", firstname:results.rows.item(i).firstname, secondname:results.rows.item(i).secondname, date_of_birth:results.rows.item(i).date_of_birth }) } }) } ListModel { id: myModel ListElement { firstname: " " secondname: " " date_of_birth: "" } } TableView { id: myTable model: myModel TableViewColumn { role: "firstname" title: "First Name" } TableViewColumn { role: "secondname" title: "Second Name" } TableViewColumn { role: "date_of_birth" title: "Date of Birth" } }
-
Hi,
You can start by the SQL Programming chapter in Qt's documentation.