QSqlQueryModel is read-only and reads only when setQuery() is called. Read-write models like QSqlTableModel track changes when they are made through the model.
There is no single mechanism that Qt can use to receive notification from an underlying database engine about external changes that is supported or adaptable across all the databases supported by Qt. Oracle, Postgresql, and Sqlite have mechanisms to announce changes: all different of course. MySql has, AFAICT, no notification mechanism at all. ODBC is a generic abstraction that the Qt abstraction is built on top of: it seems unlikely notifications would make it through. Qt does not expose the notification mechanism in Sqlite if db.driver()->hasFeature(QSqlDriver::EventNotifications) is to be believed. If it were exposed you could use the QSqlDriver functions to subscribe.
You can refresh your QSqlQueryModel by recalling setQuery() with the query(). Calling model->query()->exec() may work (I have not tried). You will probably lose selections in attached views and a few other things.
Bookmarks