Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QVariant list
Qt 6.11 is out! See what's new in the release blog

QVariant list

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 2.2k Views 1 Watching
  • 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 Offline
    M Offline
    mrsinger
    wrote on last edited by
    #1

    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
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      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
      0
      • ? A Former User

        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 Offline
        M Offline
        mrsinger
        wrote on last edited by
        #3

        @Wieland right

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved