Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native KDE look for Qt 5 app

Tags:

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.

like image 877
NIA Avatar asked Feb 14 '13 16:02

NIA


1 Answers

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.

like image 137
Nikos C. Avatar answered Sep 28 '22 17:09

Nikos C.