Commit changes to SQLite database, that can be seen between QTabs Commit changes to SQLite database, that can be seen between QTabs sqlite sqlite

Commit changes to SQLite database, that can be seen between QTabs


Could you doublecheck that

void ClientTab::updateAllServices()

is called every time as the client logs in (not only at application start)?

SQLite database has autocommit on by default, therefore you don't need to commit anything or use any transaction for this simple thing.

Can you see the new service added in sqlite command line with a select * from service? If so, then adding a service works well, and you need to check when do you call updateAllServices().


If I understand your problem correctly, it's about how to synchronize multiple views of a database. This is indeed a difficult task.

If only one of the views is visible at any given time (like it seems in your case to be with the different tabs), just reload the data from the database and repopulate the tabs. How would you do this? Add a signal contentChanged() to your main window and let all views reload the data when they see it. (Or clear their data and reload when the user switches to the specific tab.)


In case this is too slow or you can see the same content in multiple views at the same time: You should use the models provided by Qt, e.g. QListView + QAbstractListModel instead of QListWidget. If you use those, synchronization is for free, but you should not access your SQL database directly anymore and only change it through the model.