Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to highlight a row in QTableWidget?

Tags:

qt

I'm having a QTableWidget with 9000 data. I can search data from the table, like, if I search for '10', whole data starting with '10' will be displayed. Now I need to highlight the first row, since it shows the accurate search result.

I'm using:

ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); 

for highlighting the selected row.

How can I highlight the first row of table?

like image 238
Shyam Avatar asked Dec 27 '11 11:12

Shyam


1 Answers

I am not sure I am clear of why you need to set selection behavior unless you are planning for the user to be able to do the selection by clicking on the cells. And if you want that to be the default behavior then just set this as a property of the tableWidget when you use the QT designer.

But you can certainly do:

ui->tableWidget->selectRow(0);

That will highlight the row.

like image 173
Karlson Avatar answered Sep 25 '22 20:09

Karlson