PDA

View Full Version : clearing a list.....



reshma
22nd March 2009, 14:06
after clearing a list cant i append new items next tim???

navi1084
22nd March 2009, 14:15
you can... Create items using QTableWidgetItem and create a row using insertRow() and set the items.

reshma
22nd March 2009, 16:12
nooo i m askin about a Qlist....not table....

spirit
22nd March 2009, 16:17
yes you can.
try this


...
QList<int> ints;
ints << 1 << 2 << 3;
qDebug() << ints;
ints.clear();
ints << 4 << 5 << 6;
qDebug() << ints;
...

Lykurg
22nd March 2009, 16:18
after clearing a list cant i append new items next tim???
Of course you can!
QList<int> list;
list << 1 << 2 << 3;
qWarning() << list; // (1, 2, 3)
list.clear();
list << 4 << 5;
qWarning() << list; // (4, 5)
Where's the problem?

spirit
22nd March 2009, 16:19
Of course you can!
QList<int> list;
list << 1 << 2 << 3;
qWarning() << list; // (1, 2, 3)
list.clear();
list << 4 << 5;
qWarning() << list; // (4, 5)
Where's the problem?

cool! almost the same code. :D

Lykurg
22nd March 2009, 16:24
:D Reminds me of the german saying "Zwei Dumme, ein Gedanke." (In English it is I think: Great minds think alike.)...

reshma
22nd March 2009, 16:28
okay got it...

well i use append function as my QList is like this...
QList<QPair<QString, int> > instructionList; to add items...i hope its correct