[Interest] Setting the font size in QHeaderView

Glenn Ramsey gr at componic.co.nz
Mon Jun 30 00:01:28 CEST 2014


Hi,

How can I set the font size in a QHeaderView, preferably using a stylesheet?

Neither of the following seem to work (PyQt/Qt 5.2.1, OSX 10.8):

QHeaderView {
font-size: 16px;
}

QHeaderView::section {
font-size: 16px;
}

I am able to successfully set other properties such as

spacing: 10px;
background-color:lightblue;
color: white;
border: 1px solid red;
margin: 1px;

If it is not possible using a stylesheet then how can it be set using code?

The following also doesn't work (PyQt 5.2.1)

         class MyModel(QAbstractListModel):
             ...
             def headerData(self, index, orientation, role):
                 if role == Qt.FontRole:
                     f = QFont()
                     f.setPixelSize(30)
                     return f

I have also posted this question on stackoverflow
<http://stackoverflow.com/questions/24442756/how-to-set-the-font-size-on-qheaderview-in-a-qtableview>

Glenn



More information about the Interest mailing list