Question

I'm developing a Qt4 app and running it under gnome, but I would really like it to use a KDE system theme (Oxygen) and color scheme (Obsidian Coast). Unfortunately, the application doesn't seem to respond to changes in systemsettings.

I am at least able to get the app to use the theme I want programmatically by setting the QStyle:

QApplication app( argc, argv );
app.setStyle(QStyleFactory::create("oxygen"));

but I don't know of any similar approach for setting the color scheme, and this is kind of ugly anyway.

Interestingly, I've already developed some PyQt4 apps on this same machine and they pick up changes in systemsettings just fine. I'm not really sure why a C++ Qt4 app would behave differently.

One more note: I've noticed that changing the window appearance via the gnome dialog will affect my C++ qt window's appearance - so perhaps Gnome is overriding my KDE configuration somehow?

Was it helpful?

Solution

The only solution I've found is to let the environment do the work for you, as noted here: https://forum.kde.org/viewtopic.php?f=17&t=90720

A snip from the posts:

So you wish to start Amarok with a different colour scheme to the rest of KDE? You can do this by having a different set of settings for it.

Open Konsole, and enter "export KDEHOME=$HOME/.kde4-amarok/" Then run "systemsettings" and configure how you would like Amarok to appear ( colour scheme, etc. ) Finally, run "amarok" to start Amarok itself.

This will work for QT applications as well, but you can't set the style from within the application like you're trying (app.setStyle(QStyleFactory::create("oxygen");) You'll have to use a slightly messier method:

sys.argv.append("--style=Oxygen")

This will read the argument from the environment, and won't make a whole new Oxygen theme instance, (assuming you've set the KDEHOME environment to somewhere in your project, and you've already customized that) and will then use that KDEHOME to read the colors from and use the Oxygen theme.

Maybe they'll change this for QT5... (The ability to set a style programmatically)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top