Petric Frank wrote: > Hello, > > i ran into an issue using transactions together with QSqlTableModel. > > Whenever i do a "QSqlDatabase::rollback ()" the QSqlTableModel internal buffer > is not updated to reflect this. So it still shows the data before the > rollback.
I'm not sure whether your "internal buffer" refers to caching of query results or edited rows. QSqlTableModel doesn't cache the query results. It's base class QSqlQueryModel just provides a model interface to QSqlQuery which wraps QSqlResult. QSqlResult has a driver-specific implementation that may or may not cache locally. QSqlTableModel does cache edited rows however. > Is there a signal or other method to detect a rollback ? > This allows me to re-load the tables and views. There is no general automatic mechanism to refresh queries when the database changes. Your application will have to do this. Probably you will want to call QSqlTableModel::select() to refresh when necessary. This resets the model and view and reverts all unsubmitted edits. You might be able to use QSqlDriver notifications to detect database changes if the driver you are using supports them. > NB.: If i do a revert or select call on QSqlDatabase having un-submitted data > after the rollback i get a 'Vector index out of range' trap from inside the > qt-lib. This might be a coding error of me. But if anyone has a similar > experience and could give me a helping hand ... > I am actually on the way of tracking down this issue. > > I currently use Qt 4.8.4 and gcc 4.5.4 on Linux (x86_64). > The database server is MariaDB 5.5.23 The scenario you describe is not completely clear to me. If you can reproduce and isolate the problem, it would probably be best to file a bug report, preferably with a simple demo. > Are there any hints ? I recommend using Qt 5 if possible. There are significant behavior changes in QSqlTableModel that might be of benefit, and you can avoid the extra work of porting your application to Qt 5 later. Mark _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest