Native KDE look for Qt 5 app

NIA picture NIA · Feb 14, 2013 · Viewed 7.5k times · Source

I installed Qt5 along with Qt4 on my Kubuntu 12.10 linux machine and noticed the following:

  • Program compiled with Qt4 has native KDE look and feel. I use default KDE's Oxygen theme and so does my program (note smooth gradient with title and blue selection of focused widget);
  • But when recompiled with Qt5 without any changes to code, it uses different style (seems like it is called Fusion) and it looks awkward and out-of-place (see right pic)

Native look of Qt4 appNOT native look of Qt5 app

What I want is pretty straitforward: I want my app to fit surrounding system, i.e. look native always. When using Qt4, I'm used to having this by default. Qt5 also seemed to have normal native look in Windows. But what do I have to do to have the same in Kubuntu as well? And, ideally, everywhere? I mean, I do not want to force linux build of my app to strictly use Oxygen. I want it to use the theme that is currently set in KDE: just like it was in good old Qt4.

It seems like app code is not relevant to this issue: I didn't play with any QStyle's in it, it's pretty much typical Qt's hello-world. But just in case it's on GitHub.

UPD: @peppe has given pretty sufficient answer on why this problem happens (Oxygen theme in KDE is compiled against Qt4 and not usable by Qt5). But I'm still looking for the answer on how to fix this? I tried to find Oxygen theme source to play around with, but didn't find anything except Firefox theme.

UPD2: @kwirz suggested an interesting idea: force the app to use GTK+ theme, and enable oxygen-gtk in KDE settings that makes GTK windows look similar to Oxygen. On the one hand, it indeed looks closer to Oxygen:

Semi-native look of Qt5 app using oxygen-gtk

But on the other hand, we already see the little differences: readonly line edit turns gray, focused button is still not hightlighted, etc. Unfortunately, when trying to apply this technique to more complex widgets, even more artifacts appear (especially on combo box and spinner):

Artifacts on QComboBox and QTimeEdit using oxygen-gtk

So it seems like this techique cannot be a complete solution, but still very useful is simple cases.

Answer

Nikos C. picture Nikos C. · Feb 17, 2013

Oxygen is part of KDE, so that's where you find it. It's not a stand-alone theme. You cannot build KDE against Qt 5, it's not supported. The next major version of KDE (KDE 5) will be using Qt 5.

So right now, there's absolutely nothing you can do. If you want your application to look and behave nice in KDE 4, use Qt 4.