开发者

How to keep header from being selected when there is one item in a QTableWidget?

开发者 https://www.devze.com 2023-01-12 10:33 出处:网络
I can\'t seem to keep the horizontal header from being selected when I select a single row in a QTableWidget.

I can't seem to keep the horizontal header from being selected when I select a single row in a QTableWidget.

Example:

How to keep header from being selected when there is one item in a QTableWidget?

How can I prevent the header from b开发者_如何学Ceing selected too? This only happens when one row is in the table. If it has more than two rows, then it works as expected and only the row itself is selected.


Note: I have set

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

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


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


Maybe method setHighlightSections() can help:

ui->tableWidget->horizontalHeader()->setHighlightSections(false); 
0

精彩评论

暂无评论...
验证码 换一张
取 消