Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Remove the Header in QTableView?

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).

like image 585
New Moon Avatar asked Sep 10 '13 07:09

New Moon


2 Answers

From your comments in the other answer, I wonder if, by 'it should not display the whole header section', you mean you want to remove the header altogether.

If so, here's how:

myTable->horizontalHeader()->hide();
like image 165
Michael Scheper Avatar answered Oct 28 '22 10:10

Michael Scheper


You can stretch the last column to take all the avaiable space using the stretchLastSection property:

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

Or you can hide it with a stylesheet:

myTable->setStyleSheet("QHeaderView {background-color: transparent;}");
like image 33
thuga Avatar answered Oct 28 '22 09:10

thuga