QSqlQueryModel for dynamically changed information

339 Views Asked by At

Trying to build an application with a UI in QML and accessing data from a Sqlite database.

The QML view has a TableView to display information in a data grid with a model in C++.

The model is a class inheriting from QSqlQueryModel with a query to the database: setQuery("SELECT * FROM Samples", GetDataBase())

I am adding a new row in the database table every second in another thread.

When I navigate to the view where the TableView is placed, the grid is populated with the information in the table. All good. But then, every time I add a new row I call setQuery again but the table is not updated. If I go back and forth to the view again it is populated with all the new rows.

I thought the view was "automatically" notified whenever the model changed but I suppose I am missing any kind of notification to let the view know that there is new rows or something??

Also...this is just a testing application but I foresee that in my real app the information to be displayed in the grid will change very fast and the table can have several rows of information (order hundred thousand rows) so I wonder if QSqlQueryModel is the right model for this kind data.

0

There are 0 best solutions below