1
votes

I would like to customize the look of QTabWidget tabs themselves (the tabs that we actually click to switch to another tab widget) by changing their height and width (which on OS X look more like pushButtons). How to achieve this?

from PyQt4 import QtGui
app=QtGui.QApplication([])

dialog = QtGui.QDialog()
dialog.setLayout(QtGui.QVBoxLayout())
tab_widget = QtGui.QTabWidget(dialog)

dialog.layout().addWidget(tab_widget)
tab_widget.addTab(QtGui.QWidget(), "First")
tab_widget.addTab(QtGui.QWidget(), "Second")
tab_widget.addTab(QtGui.QWidget(),"Third")
dialog.show()
app.exec_()

enter image description here

1

1 Answers

2
votes

On OS X, the size of these elements is fixed. They will lose platform styling when you attempt to resize them. Thus you will have to come up with full tab styling on your own: overriding even one attribute drops the platform style, which can't be adjusted, and reverts full control to you.

The styling is done via QSS (Qt Style Sheets), a CSS-lookalike. Here's an example, and you'll also want to consult the documentation.