For the purpose of visualizing data from a MySQL table, a QTableView is being used in conjunction with a QSqlTableModel. How can I auto update the QTableView as new values are inserted in the database?
Thanks in advance.
Printable View
For the purpose of visualizing data from a MySQL table, a QTableView is being used in conjunction with a QSqlTableModel. How can I auto update the QTableView as new values are inserted in the database?
Thanks in advance.
You need to be notified about changes to the database and rerun the select statement. If your database does not support notifications or your data feeder does not support notifications then you need to implement such system yourself external to the database.
MySQL 5.5.24 (WAMP 2.2) is being used. Could you please provide some details on how this can be done?
Thanks in advance.
AFAICT there is no inbuilt Mysql mechanism to alert an external observer that a table has changed. You can use a trigger to detect updates but to notify an external watcher you would need to use a user-defined function (UDF) to call an external application that broadcasts the notification. Here is an example
https://help.pubnub.com/entries/2244...abase-Trigger-
(This will not scale well for high speed inserts)
You can also use a trigger to update a single row table containing a timestamp that your program can poll. When the timestamp becomes newer than your local last update time then refresh your view. Google has plenty of different variations on this theme.