Duplicate the objects in QList and append it to the same QList
-
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.
-
If i understand you correctly this method of QList should help.
-
Hi and welcome to devnet,
Out of curiosity, why do you need that "duplicate-append" operation ?
-
QList<int> list; list << 1 << 2 << 3; list += list;
-
@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? -
@fluffystub Yes list += list just appends the content of the list to the same list. Just try following after my code above:
qDebug() << list;
-
@fluffystub So you want something like a list of card pairs ?