PDA

View Full Version : How to update



unix7777
14th August 2012, 17:09
I want an application using SQLite.I use QSQlqueryModel and QTableView to display the data.
I want when data (the model) changed to update the content displayed in the QTableView.
When i click on dialog i add new data to the model and when i click on the button ADD i want to close the dialog and on the widget behind to repaint/update the displayed data.

8128

Lykurg
14th August 2012, 17:39
And the question is? All you have wrote is perfectly possible with a model and view approach.

unix7777
14th August 2012, 20:19
The question is how to update TableView?I don't use MVC pattern!There should be some method for doing this.

ChrisW67
15th August 2012, 09:07
QSqlQueryModel is read only: you cannot update the data through the model and the model has no way to know if the data underneath it has been changed externally. If you want to update the data through the model (using the table directly or a dialog that uses the model) then you want a QTableModel or similar. If you only want to refresh the read-only table because you know the underlying data has changed then call setQuery() again.

unix7777
15th August 2012, 11:48
Thank you! I just made a new slot with the query and i trigger it whenever i need an update.