How to refresh view when model data changes
i have a problem with Qtableview witch is considered like a view , and my model ( QsqlqueryModel )
i have manipulate data in the model ( delete , add , ....etc ) , but the view not updating in real time
i want a better way to informe the view with updating of model data
any one knows how we can do this ??
I'm not sure it will help, but maybe you can call update() on your QTreeView when your data change.
QSqlQueryModel is read-only. Maybe you need QSqlTableModel instead.
[quote author="chris17" date="1382593819"]QSqlQueryModel is read-only. Maybe you need QSqlTableModel instead.[/quote]
i don't want to allow users , to be able to edit cells , i need it read it only,
my problem is when other events make changes in database , and this changes affecte the my model , so, i need to update it immediatly
There are two ways of doing this. (when you read the documents you should have thought of this yourself).
This first one is the update() function of the QAbstractItemView which QTableView inherits. The second is the reset function of the QAbstractItemView.
The big difference is that the update gets an index of the positions in the table to refresh. The view does a complete rebuild, also loosing any selection behavior etc.
i have tried the two function but , they not work for me , the model still need to query the database again to be refresh
her is my code