How to change style in PyQt5
may be Cleanlooks
is no longer available on your system. By QStyleFactory.keys()
you can ask the available styles on your system. On Ubuntu 16.04 and pyqt5 i only get:
['Windows', 'GTK+', 'Fusion']
edit:
here you find the qstyleplugin
containing 6 additional styles, you have to compile it by yourself
- edit:
on ubuntu 16.04, python3.5 i got it working by installing the styleplugins to QT5 and compile pyqt5 from source against this QT5:
install QT 5.7 by onlineinstaller
in installationdirectory search qmake
, in my case /opt/Qt/5.7/gcc_64/bin/qmake
download qtstyleplugin to an arbitrary directory git clone https://code.qt.io/qt/qtstyleplugins.git
and install it:
cd qtstyleplugins
/opt/Qt/5.7/gcc_64/bin/qmake # the qmake from the fresh installation
make
make install
now there is a folder „styles“ in /opt/Qt/5.7/gcc_64/plugins/
containing the additional styles.
download sip-source, compile and install it
download pyqt5-source, compile and install it, in the step python3 configure.py
provide the qmake from the QT5-Installation by the --qmake
-option and look in the output for missing dependencies.
Now the following styles are available:
['bb10dark', 'bb10bright', 'cleanlooks', 'cde', 'motif', 'plastique', 'Windows', 'Fusion']
i got an sip-error:
RuntimeError: the sip module implements API v11.0 to v11.2 but the PyQt5.QtCore module requires API v11.3
to prevent it, run sudo apt-get purge python3-sip
before installing sip as described here
Admin
Updated on July 08, 2022Comments
-
Admin over 1 year
I am writing a Qt5 application by using PyQt. I would like to understand how to change the style of the entire application.
The old Qt4 calls like:
app = QApplication(sys.argv) app.setStyle(QStyleFactory.create('Cleanlooks'))
and the suggested method here does nothing.
Are they deprecated? https://blog.qt.io/blog/2012/10/30/cleaning-up-styles-in-qt5-and-adding-fusion/
Thank you!
-
Admin about 7 yearsthank you! Very strange, I have also ubuntu 16.04 and Qt5, I get only ['Windows', 'Fusion']. How to add/create more?
-
Admin about 7 yearsHow can I install it?
-
PNC about 6 yearsI get this error NameError: name 'QStyleFactory' is not defined
-
a_manthey_67 about 6 years
from PyQt5.QtWidgets import QStyleFactory