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.
-
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,QTableWidgetdoes 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
QTableWidgetto deal with data in a database. The most convenient way is to use theQSql...classes for the data tables and aQTableViewfor the display, which can be tied to your SQL model. -
@Dummie1138
No,QTableWidgetdoes 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
QTableWidgetto deal with data in a database. The most convenient way is to use theQSql...classes for the data tables and aQTableViewfor the display, which can be tied to your SQL model.@JonB I wasn't aware that QTableView can be tied to a SQL database, nor did I found any documentation on the QTableView documentation for this matter. Would you happen to know where this information may be stored?
-
@JonB I wasn't aware that QTableView can be tied to a SQL database, nor did I found any documentation on the QTableView documentation for this matter. Would you happen to know where this information may be stored?
-
@JonB I wasn't aware that QTableView can be tied to a SQL database, nor did I found any documentation on the QTableView documentation for this matter. Would you happen to know where this information may be stored?
@Dummie1138
Qt'sQTableViewcan view/edit anything which supplies theQAbstractItemModelmodel interface.QSqlQueryModelprovides a read-only model for an arbitrarySELECTquery.QSqTableModelprovides a read/write model for a SQLTABLE.QTableViewcan have either of these as itssetModel(). It allows update editing for the latter one.QTableWidgetis a "convenience" widget. It derives fromQTableViewbut 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.