Sending XmlListModel contents to a database
-
Hi all,
I'm learning as I go along. Mucking around with QML and javscript.
Currently I have an XmlListModel that populates a ListView. I want to send that xml data (about 100 entries) to be stored using javascript and sqlite.
Originally I thought I could store the xml data by calling a javscript function (e.g. saveItem(model);) within the ListView -- this would work for any visible list items, but wouldn't commit the entire list because the function was only being called as each list item was created (i.e. as I scroll).
What would be the best way to send the contents of my XmlListModel to a database?
-
Hi,
I had the same issue, I came across a js library called "persistencejs". It works with QML so you can give it a try.
lib -> http://persistencejs.org/
use this for reference https://github.com/fgrehm/QtGas
-
I was doing something similar, but in the end decided to use load my xml using XMLHttpRequest, pick the data I needed from the xml dom result into a database and the load the data from the database into my model when needed. A bit more work, but if the XML is even a bit more complex then the XmlListModel can't handle it (lists inside lists for example).