Comparing two QSqlFields



  • Hello,

    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");
    field1.setValue(QVariant(QString("1")));
    QSqlField field2("task_id");
    field2.setValue(QVariant(QString("1")));
    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?


  • Lifetime Qt Champion

    Hi,

    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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.