PDA

View Full Version : sorted table



reshma
14th March 2009, 03:47
hiiii

i need to sort my table in ascendin order after adding a row to my table..
i wrote dis::


QPair<int,int> item ;
item.first=phyaddr;
item.second=y;
memoryList.append(item);
table->insertRow(table->rowCount());
QTableWidgetItem *fir = new QTableWidgetItem();
QTableWidgetItem *sec = new QTableWidgetItem();
fir->setText(QString::number(phyaddr));
sec->setText(QString::number(y));
table->setItem(row, 0, fir);
table->setItem(row, 1, sec);
table->sortItems(0,Qt::AscendingOrder );

i also tried dis while creating the table in addition to above code without the last line::


table->sortByColumn(0,Qt::AscendingOrder);
table->setSortingEnabled(true);

bt the problem with dis is the addition of the row is not takin place correctly....

its adding first column to first row..n second col is remainin blank
the second col is changed in the last row...

thus a total mess...wat do i do..????