KDE and GTK integration for Qt app

Hello folks. I wonder if there is a way to integrate KDE and GTK support for a Qt app at the same time for an app like https://github.com/pbek/QOwnNotes/blob/develop/snap/snapcraft.yaml.

So if someone runs qownnotes on KDE it gets the KDE look and feel and if someone runs it on Gnome it gets the GTK look and feel.

1 Like

Hi there, I’m not entirely sure if that’s exactly what you are thinking about, but anyway.

I recently implemented a feature to the mGBA snap (at https://github.com/popey/mgba-snap/pull/5). What this does is that it will explicitly set the GTK theming to use the qt5-style-plugins. This shouldn’t affect the theming when running natively on KDE at all, on GTK, it will default to said Qt5 theming.

If you want to take a look at the screenshots: This shows the Qt based application running on “stock” Ubuntu 19.10.

Relevant here are the first/oldest three commits.

Thank you for your example. I currently do almost the same. I use QT_QPA_PLATFORMTHEME: gtk3 (for file dialogs and so on) but override it with the Breeze theme for the looks.

My most desired outcome would be that if someone runs qownnotes on KDE Plasma the app gets the KDE Plasma look and feel and if someone runs it on Gnome it gets the GTK look and feel.

1 Like

I think the key part here is that you shouldn’t use gtk3 for QT_QPA_PLATFORMTHEME, but gtk2 as I did in my example. From what I understood while researching this before I was able to update the mGBA snap, that’s because somehow the qt5-style-plugins are meant to be used that way - maybe you could give this a try?

If you want a really deep integration in both DEs, then I think that’s something that should be adressed in the application itself - I don’t think that’s specific to being a snap…

You are right, I could simply check for KDE env variables to decide which style I use.

I don’t know, I wasn’t able to use kio-slaves while I was testing the kde-plasma integration, so I pivoted back to the gtk3 styles, that also look nice