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. Duplicate the objects in QList and append it to the same QList

Duplicate the objects in QList and append it to the same QList

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 1.6k Views
  • 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.
  • F Offline
    F Offline
    fluffystub
    wrote on last edited by
    #1

    I am creating an app that takes in data.
    I have created a QList with all the data that is entered. Now i want to duplicate it and append it to the end of the QList.
    How to do that?

    PS: C++ and Qt newbie here.

    jsulmJ 1 Reply Last reply
    0
    • M Offline
      M Offline
      MatrixSan
      wrote on last edited by
      #2

      If i understand you correctly this method of QList should help.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        Out of curiosity, why do you need that "duplicate-append" operation ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        F 1 Reply Last reply
        0
        • F fluffystub

          I am creating an app that takes in data.
          I have created a QList with all the data that is entered. Now i want to duplicate it and append it to the end of the QList.
          How to do that?

          PS: C++ and Qt newbie here.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @fluffystub

          QList<int> list;
          list << 1 << 2 << 3;
          list += list;
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • SGaistS SGaist

            Hi and welcome to devnet,

            Out of curiosity, why do you need that "duplicate-append" operation ?

            F Offline
            F Offline
            fluffystub
            wrote on last edited by
            #5

            @SGaist I am building a game similar to a memory game i.e the user is allowed to flip a card and match it with the card with same data(that is also hidden, only two cards are visible at a time).
            this calls for a duplication right?

            jsulmJ 1 Reply Last reply
            0
            • F fluffystub

              @SGaist I am building a game similar to a memory game i.e the user is allowed to flip a card and match it with the card with same data(that is also hidden, only two cards are visible at a time).
              this calls for a duplication right?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @fluffystub Yes list += list just appends the content of the list to the same list. Just try following after my code above:

              qDebug() << list;
              

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @fluffystub So you want something like a list of card pairs ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1

                • Login

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