[ACCEPTED]-Hiding row labels-pyqt

Accepted answer
Score: 49

I was wondering about the same thing. However, I 8 was too lazy to find a solution till you 7 asked. (Thanks!!). Anyway, here is the code 6 that worked for me:

    table = QtGui.QTableWidget()
    table.verticalHeader().setVisible(False)

These are actually QTableView's methods. Since 5 you use a QTableWidget which is a child of QTableView, everything 4 works out.

I am not sure whether this is 3 the best way to do this, but the QHeaderView documentation 2 recommends this method. To quote the PyQt4 1 docs-

Appearance

QTableWidget and QTableView create default headers. If you want the headers to be visible, you can use setVisible().
Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header's setItemDelegate() function will have no effect.
Score: 6

You can also put your data in a QTableView 2 object and hide the vertical row header 1 with a hide() function. Here is the sample code,

 QTableView *empview = new QTableView();
 empview->verticalHeader()->hide();
Score: 0

Now you can just use method:

setHeaderHidden(true);

inherited from QTreeView. It 1 was introduced in Qt4.4.

More Related questions