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
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 1.7k 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.
  • F Offline
    F Offline
    fluffystub
    wrote on 13 Dec 2016, 19:47 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.

    J 1 Reply Last reply 14 Dec 2016, 05:36
    0
    • M Offline
      M Offline
      MatrixSan
      wrote on 13 Dec 2016, 20:24 last edited by
      #2

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 13 Dec 2016, 21:25 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 14 Dec 2016, 09:15
        0
        • F fluffystub
          13 Dec 2016, 19:47

          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.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 14 Dec 2016, 05:36 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
          • S SGaist
            13 Dec 2016, 21:25

            Hi and welcome to devnet,

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

            F Offline
            F Offline
            fluffystub
            wrote on 14 Dec 2016, 09:15 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?

            J 1 Reply Last reply 14 Dec 2016, 11:46
            0
            • F fluffystub
              14 Dec 2016, 09:15

              @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?

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 14 Dec 2016, 11:46 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
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 14 Dec 2016, 21:18 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

                2/7

                13 Dec 2016, 20:24

                5 unread
                • Login

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