Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Comparing two QSqlFields
Zerby last edited by
I need to see if two QSqlFields have the same field name and value. I have QSqlFields loaded from SQLITE database, and when I compare them to a field I have just created, with the same field name and value, the == -operator still returns false. Is there something else the == -operator checks than field name and value of the two QSqlFields? If I simply create two fields:
@ QSqlField field1("task_id");
if (field1 == field2) showmessage(1);@
Comparing them works fine (returns true), but not with the loaded fields from an actual database...
Note, I actually need to compare two QSqlRecords, but it seems the problem lies in QSqlField -level.
EDIT: Now that I think of it, the values probably aren't loaded as QVariant(QString()) -format, which I've used to test it. Does anyone know how (QVariant(??)) are the values loaded from the database?
IIRC, the variant type will depend on the content of the database, you could check your two fields type to see if they match.
Hope it helps