This feature is not supported by Qt. When a table is altered, there is no notification mechanism to update the model and view automatically. Although you can do it in PostgreSQL in some way as stated here but in SQLite you need to query the database periodically and update the view which is costly. An other option is to use QFileSystemWatcher
to catch file changes and update the view on time:
QFileSystemWatcher *databaseWatcher = new QFileSystemWatcher(this);
databaseWatcher->addPath("Path/To/database.sqlite");
QObject::connect(databaseWatcher, SIGNAL(fileChanged(QString)), this, SLOT(refreshView()));
Now it watches the database file and when ever it's changed by an external process or by your self, fileChanged
signal is emitted and refreshView
slot is called in which you should update the model and view.