6

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!

Diggy.
  • 6,744
  • 3
  • 19
  • 38
David Pasquale
  • 61
  • 1
  • 1
  • 2

1 Answers1

8

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

  1. 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

Community
  • 1
  • 1
a_manthey_67
  • 4,046
  • 1
  • 17
  • 28