PDA

View Full Version : how to perform search in QTableWidget?



aurora
4th January 2012, 17:33
hi all,
I want to perform a search operation in a table widget and want to highlight the row which contains particular word(key used for searching).
Please somebody tell me is that possible?

Lykurg
4th January 2012, 18:31
Loop through the elements or see QSortFilterProxyModel.

aurora
5th January 2012, 04:04
Thank u....
I tried like this....



QList<QTableWidgetItem *> LTempTable =temp->findItems("001",Qt::MatchEndsWith);

cout<<"the matched count:"<<LTempTable.count()<<endl;
foreach(rowPtr,LTempTable)
{
rowPtr->setBackground(Qt::red);
}




But it is highlighting only that particular item, i want to highlight that whole row...
How can i do that?

ChrisW67
5th January 2012, 04:25
Put in a for loop and set the background on all items in the same row as the matched item.

Alternatively you could use the QTableWidget selection with selection mode QAbstractItemView::ExtendedSelection and selection behaviour QAbstractItemView::SelectRows.