Important: Please read the Qt Code of Conduct -

QVariant list

  • I have a QVariant _list which get sets to a QVariant(list) where list is QList<QVariant> list;

    mylist contains the result of a database query. On the next query, I want to append the new results to the existing one. I tried this

    QList<QVariant> tmp = _list.toList();

    tmp +=  tableMessages.getSystemMessages( _limit , _page, _message_type, _subsystem );
    _list = QVariant(tmp);

    But then I end up with a QVariantList which is not what I want.

  • Hi, and welcome to the Qt Forum!
    I'm not sure if I understood you correctly. You got this: QList<QVariant> list to store all your QVariant values. Now you read something from a database: QList<QVariant> newData. And you want to append newData to list, right?

  • @Wieland right

  • Ok, so how about this:

        QList<QVariant> list;
        for (int i=0; i<10; i++) {
            QList<QVariant> newData;
        qDebug() << list;

    Does that do what you want?

Log in to reply