Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix theme for PyQt5 applications?

I've tried using PyQt5 from pip as well as apt (python3-pyqt5) on the same system. Both of these versions result in different themes (the images are below).

I've tried setting the environment variable QT_STYLE_OVERRIDE to "gtk" as well as "gtk+", but couldn't get the native look.

I'm curious about why this is happening. How can I force it to use QGtkStyle? Other native apps like Clementine, VLC, Zeal work with QGtkStyle theme and also blend as per gnome-shell theme.

Following some online instructions, I tried qt5-style-plugins, which doesn't have gtk theme.

Installed from pip (QFusionStyle):

installed from pip

Installed from apt (QGtkStyle):

installed from apt

like image 320
Himanshu Shekhar Avatar asked Oct 29 '22 15:10

Himanshu Shekhar


1 Answers

This is getting a little long for a comment so here are some things to try:

  • Setting DESKTOP_SESSION (didn't help in your case)
  • Print QApplication.style().metaObject().className(), see if it is the same for both runs. There may be other useful properties on the style object. Also
  • Print QStyleFactory.keys(), the QT_STYLE_OVERRIDE must be one of the printed values.
  • Look at Uniform look for Qt and GTK applications
  • The --style option overrides QT_STYLE_OVERRIDE setting
  • There could be a plugin style that gets activated in one of the installations
like image 160
Oliver Avatar answered Nov 01 '22 04:11

Oliver