Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PyQt not using Qt themes on Linux
Forum Updated to NodeBB v4.3 + New Features

PyQt not using Qt themes on Linux

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 5.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AbeStew
    wrote on 8 Jan 2018, 01:24 last edited by AbeStew 1 Aug 2018, 08:29
    #1

    I am running Ubuntu 17.10 and having difficulty getting PyQt to use the system theme. Since Gnome is the default desktop I have used Kvantum Manager to specify ArcDark as the system Qt5 theme. This works in the majority of applications - including Qt 5 Designer! However, running any scripts I've written using PyQt5 (installed via conda) defaults to Windows when run.
    It looks like PyQt only has Windows and Fusion as inbuilt stylesheet options -

    >>> from PyQt5.QtWidgets import QStyleFactory
    >>> print(QStyleFactory.keys())
    ['Windows', 'Fusion']

    In Qt Designer though the options are: Breeze, bb10dark, bb10bright, kvantum-dark, kvantum, cleanlooks, gtk2, cde, motif, plastique, Windows, Fusion.
    I also tried installing PyQt from pip, which overrides the conda install (conda remove pyqt proposes removing whole bunch of core anaconda packages for some reason). However, it defaults to Fusion style but at least provides the error message "QApplication: invalid style override passed, ignoring it." Again only Windows and Fusion are recognised QStyleFactory keys for some reason.
    Does anyone know a way to fix this? Alternatively, is there anyway to use the files from arc-kde github to manually specify the style for each script? Thanks in advance.

    J 1 Reply Last reply 8 Jan 2018, 11:21
    0
    • A AbeStew
      8 Jan 2018, 01:24

      I am running Ubuntu 17.10 and having difficulty getting PyQt to use the system theme. Since Gnome is the default desktop I have used Kvantum Manager to specify ArcDark as the system Qt5 theme. This works in the majority of applications - including Qt 5 Designer! However, running any scripts I've written using PyQt5 (installed via conda) defaults to Windows when run.
      It looks like PyQt only has Windows and Fusion as inbuilt stylesheet options -

      >>> from PyQt5.QtWidgets import QStyleFactory
      >>> print(QStyleFactory.keys())
      ['Windows', 'Fusion']

      In Qt Designer though the options are: Breeze, bb10dark, bb10bright, kvantum-dark, kvantum, cleanlooks, gtk2, cde, motif, plastique, Windows, Fusion.
      I also tried installing PyQt from pip, which overrides the conda install (conda remove pyqt proposes removing whole bunch of core anaconda packages for some reason). However, it defaults to Fusion style but at least provides the error message "QApplication: invalid style override passed, ignoring it." Again only Windows and Fusion are recognised QStyleFactory keys for some reason.
      Does anyone know a way to fix this? Alternatively, is there anyway to use the files from arc-kde github to manually specify the style for each script? Thanks in advance.

      J Online
      J Online
      JonB
      wrote on 8 Jan 2018, 11:21 last edited by
      #2

      @AbeStew
      If you do not get an answer for this here, I would recommend you consider joining PyQT mailing list pyqt@riverbankcomputing.com and posting there.

      1 Reply Last reply
      2
      • A Offline
        A Offline
        AbeStew
        wrote on 8 Jan 2018, 12:47 last edited by AbeStew 1 Aug 2018, 12:50
        #3

        Thanks @JonB. Dropped them an e-mail.

        Further internet searching on the issue suggests that since pyqt (and same will apply to pyside) on conda and pip are pre-built wheels they do not recognize system themes. Conda defaults to Windows as they must have built pyqt on a Windows machine. Installing via apt python3-pyqt* and using the system Python (rather than the Anaconda install of Python) half works. It shows the right colours, but retains much of the overall Fusion look. The terminal also logs gtk errors when launching system file pickers etc. A few folk seem to have got alternative default themes (Plastique, CleanLooks etc) to work with PyQt by building it against a local install of Qt and qtstyleplugins. However, not found any threads on anyone having success with that using a custom theme. Not exactly the easiest to maintain solution either.

        I am starting to think the best solution may be using a qss style sheet - with added benefit that could add a style picker dialogue that would let Windows users have a dark theme as well. Still a beginner with Qt so unsure if a qss file alone would be enough to provide a ArcDark look beyond the colours though?

        J 1 Reply Last reply 8 Jan 2018, 13:22
        0
        • A AbeStew
          8 Jan 2018, 12:47

          Thanks @JonB. Dropped them an e-mail.

          Further internet searching on the issue suggests that since pyqt (and same will apply to pyside) on conda and pip are pre-built wheels they do not recognize system themes. Conda defaults to Windows as they must have built pyqt on a Windows machine. Installing via apt python3-pyqt* and using the system Python (rather than the Anaconda install of Python) half works. It shows the right colours, but retains much of the overall Fusion look. The terminal also logs gtk errors when launching system file pickers etc. A few folk seem to have got alternative default themes (Plastique, CleanLooks etc) to work with PyQt by building it against a local install of Qt and qtstyleplugins. However, not found any threads on anyone having success with that using a custom theme. Not exactly the easiest to maintain solution either.

          I am starting to think the best solution may be using a qss style sheet - with added benefit that could add a style picker dialogue that would let Windows users have a dark theme as well. Still a beginner with Qt so unsure if a qss file alone would be enough to provide a ArcDark look beyond the colours though?

          J Online
          J Online
          JonB
          wrote on 8 Jan 2018, 13:22 last edited by JonB 1 Aug 2018, 13:22
          #4

          @AbeStew
          I am very much a beginner at Python/PyQt/Qt.

          This is probably OT, but reading what you are saying about "installation" you are probably ahead of me.

          I install everything via standard apt-get, with no extra configuration or search paths. And everything "works". However (because of my IDE, PyCharm) I would like to use pip (or rather, pip3) to install PyQt5. However, when I do so it craps up the system, such that the application no longer runs. I have tried this on various releases of Ubuntu, and they all go wrong. It is something to do with pip3 not correctly computing/downloading the dependencies --- no matter what anyone says, it gets it wrong; I have to uninstall the whole pip3 stuff to get it working again. Hence I have had to completely steer of any pip3 stuff.

          I should probably try the PyQt forum myself for this sometime....

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nshiell
            wrote on 14 May 2020, 21:43 last edited by
            #5

            I've seen this issue too, on Debian I've always found it much better to install PyQt via apt rather than Pip!

            Hence my instructions here: https://github.com/nshiell/blue-log-viewer

            The big issue now is that I can't package my app into an AppImage and get the styling to work.
            The AppImage should have PyQy bundled in it, but the version inside the AppImage can't then inherit styling from the desktop.

            Fixing this is way beyond me and there is a heck of a lot of movement on KDE desktops with theming and application packaging.

            When we have goodies like AppImage, Snappy, Flatpack and also Kvantum all existing at once I think PyQt theming is going to be tricky to get right :(

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved