QVariant reading wrong type?

  • Is there anyway to force some QSqlQuery values to be of a defined type?

    My problem:
    I have a sqlite database and one of the fields is of type VARCHAR, sometimes when I read it there are only numbers there and it may start with a zero. The problem is, Qt automatically assigns the type qlonglong to it and removes the first 0.

  • It seems like sqlite is responsible for the wrong type, I couldn't find much about it.

    @QString string = "01234";
    QVariant var(string);

    qDebug() << var << string;@

    @QVariant(QString, "01234") "01234" @

Log in to reply