Comparing a QList<QStringList> and the contents of a QTableWidget
-
I am building a save button and I want a popup that shows up when the user leaves the page containing the QTableWidget, if the information in the QTableWidget has not yet been saved to an SQL database. Therefore, I would like to compare the contents of the QTableWidget and that of the SQL data, represented in a QList<QStringList>. I am wondering whether there are any functions in QTableWidget that recovers the QStrings in the QTableWidget. and compiles them into a QStringList or a QList. Failing that, any other methods of comparing the contents of a QTableWidget and a QList<QStringList> would also be welcome.
-
@Dummie1138
No,QTableWidget
does not have anything for its data to do with lists or string lists. Just write the code to do whatever comparison you want.Incidentally, it does not sound good if your are using a
QTableWidget
to deal with data in a database. The most convenient way is to use theQSql...
classes for the data tables and aQTableView
for the display, which can be tied to your SQL model. -
-
@Dummie1138
Qt'sQTableView
can view/edit anything which supplies theQAbstractItemModel
model interface.QSqlQueryModel
provides a read-only model for an arbitrarySELECT
query.QSqTableModel
provides a read/write model for a SQLTABLE
.QTableView
can have either of these as itssetModel()
. It allows update editing for the latter one.QTableWidget
is a "convenience" widget. It derives fromQTableView
but provides its own in-memory simple model.
If you use QTW with SQL you will be copying values between the query results and the inbuilt model. If you use QTV you will be accessing the SQL model directly.