8

As shown in the Image below, How can i remove the unwanted header section ?

QTableView with 4 columns

My Table has to display only 4 column headers. It should not display the whole header section. Please Help to remove the Header Section which is displaying after the 4th column (Header section which is highlighted).

4

2 回答 2

24

从您在另一个答案中的评论中,我想知道“它不应该显示整个标题部分”是否意味着您要完全删除标题。

如果是这样,方法如下:

myTable->horizontalHeader()->hide();
于 2016-06-23T14:33:41.180 回答
6

您可以使用stretchLastSection属性拉伸最后一列以占用所有可用空间:

myTable->horizontalHeader()->setStretchLastSection(true);

或者您可以使用样式表将其隐藏:

myTable->setStyleSheet("QHeaderView {background-color: transparent;}");
于 2013-09-10T07:58:45.383 回答