Pyqt window style can be configured.
The default style of PyQt is called ‘Fusion’. But this isn’t the only style, there are many styles or themes like ‘QtCurve’, ‘Windows’ and others.
You may want to distribute your app on multiple operating systems, and have a native look and feel. To do that, you change the theme.
If you are on Windows, you want the Windows look. On Mac you want the Mac OS X style. All of these can be configured. The Mac style is only available on Mac OS X.
Related Course: Create GUI Apps with Python PyQt5
PyQt style
Available styles
The available PyQt styles may differ system to system, but because many people install the PyQt binary the styles installed are often the same. You can get a list of available styles using the Python interpreter, like so:
1 | $ python3 |
The Breeze style looks like this:
Configure style
After creating the application with QApplication([])
, you can can set the Qt style with the function setStyle(style)
. For example if you want to set the style to Fusion, you add the line app.setStyle('Fusion')
.
In the example below we set the Windows style like so:
1 | app = QApplication([]) |
Then the window shows like this (the old Win 9x style):
If you are new to Python PyQt, then I highly recommend this book.