PyQt not using Qt themes on Linux

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

PyQt not using Qt themes on Linux

Alasdair B R Stewart
Hi,


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! Though it does not
appear as an option to preview in, instead only showing: Breeze,
bb10dark, bb10bright, kvantum-dark, kvantum, cleanlooks, gtk2, cde,
motif, plastique, Windows, Fusion.

As it is a pre-built wheel PyQt only has Windows and Fusion as inbuilt
stylesheet options -

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

Running any scripts I've written using PyQt5 (installed via conda)
defaults to Windows when run, likely as they built PyQt on a Windows
machine. I also tried installing PyQt from pip, which overrides the
conda install. It instead 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.

Installing python3-pyqt* and running pyqt scripts using the
/usr/bin/python3.6 half works. The colours and some of the layout are
now ArcDark but there remain a few Fusion elements - guessing there is a
gtk theming issue here.

Does anyone know a way to fix this? Ideally, I would want this to run
with the conda version of python. Alternatively, is there anyway to use
the files from arc-kde github to manually specify the style for each
script?


Thank you,


Alasdair


P.S. Apologies if this is a duplicate threat - unsure if my first e-mail
sent correctly.

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: PyQt not using Qt themes on Linux

Giuseppe Corbelli
On 01/08/2018 11:38 AM, Alasdair B R Stewart wrote:

> Hi,
>
>
> 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! Though it does not
> appear as an option to preview in, instead only showing: Breeze,
> bb10dark, bb10bright, kvantum-dark, kvantum, cleanlooks, gtk2, cde,
> motif, plastique, Windows, Fusion.
>
> As it is a pre-built wheel PyQt only has Windows and Fusion as inbuilt
> stylesheet options -
>
>  >>> from PyQt5.QtWidgets import QStyleFactory
>  >>> print(QStyleFactory.keys())
> ['Windows', 'Fusion']
>
> Running any scripts I've written using PyQt5 (installed via conda)
> defaults to Windows when run, likely as they built PyQt on a Windows
> machine. I also tried installing PyQt from pip, which overrides the
> conda install. It instead 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.
>
> Installing python3-pyqt* and running pyqt scripts using the
> /usr/bin/python3.6 half works. The colours and some of the layout are
> now ArcDark but there remain a few Fusion elements - guessing there is a
> gtk theming issue here.
>
> Does anyone know a way to fix this? Ideally, I would want this to run
> with the conda version of python. Alternatively, is there anyway to use
> the files from arc-kde github to manually specify the style for each
> script?

Not sure if I completely understand but:
*) styles are defined as QT plugins
*) you can manually set the style with QApplication::setStyle

If you want to use the same style the relevant plugin must be accessible
by the Qt installation you're using but should be loadable explicitly
with QPluginLoader.

This is not pyqt specific stuff however.

--
Giuseppe Corbelli
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt