Hello!
Giving my understading of Qt's model system, I developed a software which displays, in QListViews, the content of a field from a SQLite based table. I imagined that, by using the query model, each time I updated my table, the query would automatically notice it and update the items on the QListView.
For my unhappiness, that didn't ocurr, and now the QListViews are only updated when the software is closed and reopened. Based on this comes my first question: wasn't QSqlQueryModel supposed to update when the database is changed? Is there something lacking? Or this is not the appropriate class to do such a work while there is another class that do so?
Now after noticing this, I tried to find a way to manually update the model, that is, make it call the QSqlQuery once again after the database is updated. But unfortunately (I'm using Qt 5.1) I couldn't find any method to do such work. I even found this¹ topic that talks about this, but it didn't give me any working solution :T So my second question is: is there a way to update the model programatically once I know that the database was changed? And, more specifically, is there a way to do this without having to call a method each time it ocurrs, but in a smarter way? (like reimplement QSqlDatabase with a new signal that is emitted each time the database is changed).
Thanks,
Momergil
¹: http://www.qtcentre.org/threads/2959...-query-changes
Bookmarks