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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With