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!
one of the coolest feature in PyQt5 is the ability to design themes using the CSS , CSS is an easy way to design awesome themes with easy selectors , we will not talk about the available selectors in PyQt5 because not all the CSS selectors available in PyQt5 but we will take a look at some cool themes made with other ...
use setFont() : it sets the default font for the target; you can get the current default font using something. font() , then use font. setPointSize() (or setPointSizeF() for float values, if the font allows it) and then call setFont(font) on the target.
PyQt is a Python binding for Qt, which is a set of C++ libraries and development tools that include platform-independent abstractions for Graphical User Interfaces (GUI), as well as networking, threads, regular expressions, SQL databases, SVG, OpenGL, XML, and many other powerful features.
Advantages of PySide PySide represents the official set of Python bindings backed up by the Qt Company. PySide comes with a license under the LGPL, meaning it is simpler to incorporate into commercial projects when compared with PyQt. It allows the programmer to use QtQuick or QML to establish the user interface.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With