2

I am trying to set custom style to my PyQt5 application using the setStyle() method but it doesn't work.

I am also not entirely sure about where this should be put.

In my main I tried doing :

if __name__ == '__main__':

    QApplication.setStyle("mac") #here
    app = QApplication(sys.argv)
    splash_pix = QPixmap('../resource/logo.png')
    start = time.time()
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.show()
    while time.time() - start < 1:
        time.sleep(0.003)
        app.processEvents()
    ex = Fy360()
    splash.finish(ex)
    sys.exit(app.exec_())

Edit : Upon importing from PyQt5.QtWidgets import QStyleFactory and printing the QStyleFactory.keys() I gotthe output as:

[u'Windows', u'Fusion']

why are there only these options?

Whats going wrong here?

14
  • You can run the following command: from PyQt5.QtWidgets import QStyleFactory; print(QStyleFactory.keys()) and show us what you Commented May 13, 2017 at 22:44
  • @eyllanesc sorry for the late reply, I did as you said but I got no output!. what does that mean? Commented May 14, 2017 at 4:44
  • @eyllanesc I'm sorry I did a mistake, I tried to print the keys in a function hence I got no output but when I tried it in my main I got this [u'Windows', u'Fusion'] Commented May 14, 2017 at 4:50
  • Those are the styles you can use. What is your OS? Commented May 14, 2017 at 5:03
  • 1
    Some styles are dependent on the OS, others are not, for example the Mac style is only for Mac OS, or for example fusion is compatible for several OS. Commented May 14, 2017 at 5:15

1 Answer 1

3

Some styles are dependent on the OS, others are not, for example the Mac style is only for Mac OS, or for example fusion is compatible for several OS.

Some styles (for example gtk) can be configured as follows:

Based on the discussion :

  • Install qt5-styleplugins and qt5ct
  • Set environment variable in /etc/environment QT_QPA_PLATFORMTHEME=qt5ct
  • Restart the system
  • Start qt5ct and select gtk2
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.