You are not logged in.
Hello there!
I'm working on making my Qt apps look like GTK apps. I've installed qt5ct and configured the settings, but I'm running into an issue. In other distros, I set the QT_QPA_PLATFORMTHEME=qt5ct variable either in /etc/environment or with export QT_QPA_PLATFORMTHEME=qt5ct in ~/.profile, and it works fine.
However, on Boron, both methods are failing. It seems like the QT_QPA_PLATFORMTHEME variable is being overridden with the value "gtk2".
Has anyone got any suggestions on how to fix it?
PS: running in terminal QT_QPA_PLATFORMTHEME=qt5ct and then a qt application works as expected.
Last edited by andrianos (2025-02-12 16:57:06)
Offline
^ First of all, welcome to the BL forums.
Have you tried LogOut/LogIn?
Have you tried adding the command QT_QPA_PLATFORMTHEME=qt5ct as a startup application?
I found this in my archives:
Ubuntu 20.04 – Qt Applications (VLC) Dark Theme
Open Terminal :
sudo apt install qt5-style-plugins
echo "export QT_QPA_PLATFORMTHEME=gtk2" >> ~/.profile
LogOut/LogIn
Last edited by marens (2025-02-11 13:04:04)
If people would know how little brain is ruling the world, they would die of fear.
Offline
QT_QPA_PLATFORMTHEME=qt5ct is an old method, for Qt versions later than 4.5 @maren's suggestion is correct.
No need for the entire qt5-style-plugins metapackge though, I think qt5-gtk2-platformtheme is the only package you need to make Qt look like GTK.
Offline
I'm having the same issue, not running Boron but still a Debian bookworm based system. Haven't been able to get my one QT prog to work with it (VLC). Have installed both of the qt5 platform theme packages, tried adding the plugins meta-package as well.
Tried varying the command in .profile too, still no joy, got the blinding white VLC menus still.
Should I try adding the newer command "export QT_QPA_PLATFORMTHEME=gtk2" as a startup app?
Offline
Should I try adding the newer command "export QT_QPA_PLATFORMTHEME=gtk2" as a startup app?
It's an environmental variable rather than an application so add the line to ~/.xsessionrc instead.
EDIT: if you're using LightDM see johnraff's post here for an explanation as to why ~/.profile isn't being read and how to fix that.
Last edited by Head_on_a_Stick (2025-02-11 20:55:27)
Offline
WOOT! That worked a treat, yes I am using lightdm, created the .xsessionrc and it worked like a charm, thank you so much! This has been bugging me for weeks now. Thanks to @johnraff and @marens too and also to @andrianos for bringing it up.
This just made my day, which kinda sucked previously as I woke up to a dead battery this morning and had to swap it out in 0 degree weather and snowfall.
Offline
Thank you all for your time!
I accidentally found a solution (A proper position in startup procedure to override the default 'gtk2'
value)
While I was trying to set the value in random config files I found a file named 'environment'
under '$HOME/.config/bunsen/'
and it worked!
SOLVED
Offline
A proper position in startup procedure to override the default
'gtk2'
value
Sorry if it wasn't clear but BunsenLabs sets that default in ~/.xsessionrc
so you can just edit that file rather than use ~/.config/bunsen/environment
to override the default.
Also, while qt5ct can be used to set a GTK-esque theme, using QT_QPA_PLATFORMTHEME=gtk2
means that qt5-gtk2-platformtheme is the only package needed; qt5ct pulls in a load of Qt dependencies which aren't really needed. [EDIT: which doesn't really matter if you want to install Qt applications anyway; please disregard]
Last edited by Head_on_a_Stick (2025-02-12 18:57:17)
Offline
Just some additional info from my own testing, posting for the database:
1. Clean system with VLC being the only pre-installed app that uses Qt.
2. VLC only pulls in a small subset of Qt, not the whole thing.
3. Installing the platformtheme package did not require any other depends to be installed at all, what was already pulled in for VLC was sufficient.
4. The qt5-style-plugins package is unneeded at least for me, all it does is pull in some pre-fab style stuff, motif, plastique, and cleanlooks.
5. The gtk3 platformtheme package would not work at all no matter what I tried, I imagine I would need to further read the documentation to enable that somehow.
6. In the end the only package I needed was qt5-gtk2-platformtheme, and the export line in .xsessionrc.
Offline
andrianos wrote:A proper position in startup procedure to override the default
'gtk2'
valueSorry if it wasn't clear but BunsenLabs sets that default in
~/.xsessionrc
so you can just edit that file rather than use~/.config/bunsen/environment
to override the default.
The difference between setting environment variables in ~/.xsessionrc
or ~/.config/bunsen/environment
is that the former will affect all sessions, and the latter BunsenLabs sessions only. So choose according to your needs.
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
BTW BunsenLabs is currently putting this in ~/.xsessionrc
:
# for qt5 apps ( needs qt5-style-plugins and libqt5svg5 )
export QT_QPA_PLATFORMTHEME=gtk2
Does that need updating for 2025? Either the gtk2 envvar setting, or the recommended packages?
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
The package description for qt5-gtk2-platformtheme claims that package and the environmental variable are all that is needed and greenjeans has kindly confirmed this with their testing.
Presumably BunsenLabs needs qt5-gtk2-platformtheme for VLC to blend in properly. I've (re)added the package to deadbang even though I don't ship any Qt applications just because it's so small and convenient.
Last edited by Head_on_a_Stick (2025-02-14 14:57:43)
Offline
Thanks @greenjeans and @Head_on_a_Stick for looking at this again.
What BL has now is the envvar setting QT_QPA_PLATFORMTHEME=gtk2 and the packages qt5-style-plugins and qt5-gtk-platformtheme.
The style-plugins metapackage pulls in the gtk2 platformtheme (+ unnecessary other stuff) while qt5-gtk-platformtheme is the gtk3 platformtheme which we don't yet know how to use. But it's there anyway.
BTW there's also a qt6-gtk-platformtheme
So if we're OK not bothering with qt6 or gtk3 support we can go on as we are I guess, though it would be nice to be able to move on...
---
Arch Wiki: https://wiki.archlinux.org/title/Unifor … plications
Last edited by johnraff (2025-02-15 06:17:39)
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
BTW there's also a qt6-gtk-platformtheme
According to the linked ArchWiki page the "gtk2" environmental variable should work for both Qt5 and Qt6 (with the venerable Trolltech.conf covering Qt4), so I presume that package is just the Qt6 equivalent for qt5-gtk-platformtheme. I will also be adding that package, thanks.
So as I understand it adding qt{5,6}-gtk{,2}-platformtheme and setting QT_QPA_PLATFORMTHEME=gtk2 should make all Qt{5,6} & GTK{2,3} applications look similar? I will have to test myself some more.
Offline
Some further testing:
1. Tried another qt5 app, Qosmic, works great looking good.
2. Again, nothing but the gtk2 platformtheme package.
Bit the bullet and installed Calibre which requires qt6, and it is _not_ abiding by the gtk theme as the qt5 apps are.
Installed the qt6-platformtheme package and still no joy. There must be some other commands needed somewhere to make the gtk3 packages work. The export line seems unique to the gtk2-platformtheme package and works fine for qt5 but i'm guessing even that might fail if a user has a gtk theme that doesn't incorporate a gtk2 component (gtkrc).
Offline
So if we're OK not bothering with qt6 or gtk3 support we can go on as we are I guess, though it would be nice to be able to move on...
There's the fly in the ointment right there....my OCD is smacking the inside of my head....for what it's worth i'll keep experimenting and testing and report any results, but i'm betting HOAS will figure it out long before I do.
I tried the qt6ct package and messed with it, but it didn't like the export line variable being "gtk2", swapping that to "qt6ct" made the GUI want to work and I was able to make some changes in the Calibre app, but it wasn't a straightforward apply-the-gtk-settings effect, it looked like crap and screwed up some fonts and the qt5 apps no longer used the gtk theme.
Offline
I think Qt6 might need https://github.com/trialuser02/qt6gtk2 but I can't find it packaged for Debian and I'm having trouble building it in trixie/Carbon.
EDIT: +1 for the OCD. I'm not gonna sleep well tonight...
Last edited by Head_on_a_Stick (2025-02-15 17:52:03)
Offline
I saw that qt6gtk2 package and was wondering about it.
Near as I can tell now, the gtk3 platformtheme packages, both qt5 and qt6 are not similar to the gtk2 package, they (and the qt5-style-plugins package) are meant to work only via the qt5ct or qt6ct GUI-control packages. The plugins package is to add more pre-fab styles to the drop down menu in the ct interface.
They don't work at all like the simple gtk2-platformtheme package and just apply the style generically and uniformly.
Still i'm tickled it's working for qt5 apps at least with gtk2. But going forward we need a similar package for gtk3 and qt6. I wonder if that qt6gtk2 package does the same trick as the gtk2-platformtheme package?
ETA: Calibre may not be the best candidate for testing qt6 apps, it's hugely configurable within it's own preferences interface, colors, fonts, etc. which may present issues getting a simple color-switch from outside the app, like I mentioned using qt6ct _did_ change it, but it didn't look like my gtk2 or 3 theme and fonts went wonky.
Need to test on a simpler qt6 app now. Update: Installed cutemaze, simple game app in qt6 and not working in it either.
Last edited by greenjeans (2025-02-15 18:58:48)
Offline
Question: Okay the gtk2-platform theme solution is elegant as even if the user changes themes the qt should follow, the issue now is with qt6 which doesn't want to abide.
So not as elegant, but for purposes of having qt6 apps at least abide by BL's default theme(s), is it not possible to simply add a .qss stylesheet file/folder in the default theme?
Sorry i'm not familiar at all with qt theming, this may be a stupid question.
I just know my chosen theme is a heavily modded hodge-podge I made from multiple themes, that works in Mate, OB, Cinnamon etc. It was originally a Mate theme, I just added an OB component to it and a different gtk2 rc and then modded colors.
Offline