Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved QVariant list

    General and Desktop
    2
    4
    1560
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mrsinger last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • ?
        A Former User last edited by

        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?

        M 1 Reply Last reply Reply Quote 0
        • M
          mrsinger @Guest last edited by

          @Wieland right

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User last edited by

            Ok, so how about this:

                QList<QVariant> list;
                list.append("old");
                list.append("data");
            
                for (int i=0; i<10; i++) {
                    QList<QVariant> newData;
                    newData.append(i);
                    newData.append("one");
                    newData.append("two");
                    newData.append("three");
                    list.append(newData);
                }
            
                qDebug() << list;
            

            Does that do what you want?

            1 Reply Last reply Reply Quote 0
            • First post
              Last post