[Development] How to override the default QPlatformTheme?

PCMan pcman.tw at gmail.com
Tue Jun 24 19:14:10 CEST 2014


Hello,
With Qt4, we can load our own custom platform plugin to do things we want.
This does not seem to be as easy in Qt 5.
We want to override the default QPlatformTheme provided by Qt with our
own plugin.
However, this part is hard-coded in Qt.
When XCB platform is used, Qt 5 loads QXcbIntegration plugin.
Then, a list of available platform themes is retriieved using
themeNames(), which in turns is redirected to
QGenericUnixThemes::themeNames().
It hard coded checks for KDE, and if KDE is not in use, Qt forced the
loading of gtk theme plugin.
Only when the preceding plugins all fail, it tries "DESKTOP_SESSION"
environment variable.
There does not seem to be a way to override this behavior.
Is it possible to force loading of my own platforn theme by using a
QT_QPA_XXX environment variable?

I know that we can develop our own platform integration plugin, but
that's too much work.
We just want to customize the platform theme part so building a new
QPlatformIntegration will be overkill.

Thank you very much.



More information about the Development mailing list