How to save title for selection if there is one element in QTableWidget?

It seems I can not display the horizontal title when I select one row in a QTableWidget .

Example:

alt text

How can I prevent header selection? This only happens when one row is in the table. If it has more than two lines, then it works as expected, and only the line itself is selected.


Note. I have installed

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

so that the entire row is selected when the user clicks on the cell.

+6
select qt header qtablewidget
source share
2 answers

I created a test and observed the same behavior, and I'm not sure what intentional behavior is. I was able to prevent this by setting horizontalHeaderHighlightSections to false, but I'm not sure if this is the optimal solution.

+7
source share

Maybe the setHighlightSections () method can help:

 ui->tableWidget->horizontalHeader()->setHighlightSections(false); 
+3
source share

All Articles