原生KDE寻找Qt 5应用 [英] Native KDE look for Qt 5 app

查看:180
本文介绍了原生KDE寻找Qt 5应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Kubuntu 12.10 linux计算机上安装了Qt5和Qt4,并注意到以下内容:

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

  • 使用Qt4编译的程序具有本地KDE外观.我使用默认的KDE的 Oxygen 主题,我的程序也是如此(请注意带有标题的蓝色渐变和焦点突出的小部件的蓝色选择);
  • 但是,当使用Qt5 重新编译而没有对代码进行任何更改时,它使用了不同的样式(似乎被称为 Fusion ),并且看上去笨拙且不合时宜(请参见右图)
  • 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)

我想要的是相当棘手的:我希望我的应用适合周围的系统,即始终看起来是原生的.使用Qt4时,我习惯于默认使用它. Qt5在Windows中似乎也具有正常的本机外观.但是,我必须怎么做才能在Kubuntu中拥有相同的功能?而且,理想情况下,无处不在?我的意思是,我不想强​​制我的应用程序的Linux构建严格使用 Oxygen .我希望它使用KDE中当前设置的主题:就像在旧的Qt4中一样.

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.

似乎应用程序代码与此问题无关:我没有玩过任何QStyle,这几乎是典型的Qt的问候世界.但是以防万一它在GitHub上.

UPD::@peppe 已给出关于此问题的充分答案发生(KDE中的氧气主题是针对Qt4编译的,无法由Qt5使用). 但是我仍在寻找有关如何解决此问题的答案? .我试图找到可以使用的Oxygen主题源,但除了 Firefox主题.

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 建议一个有趣的想法:强制应用使用GTK +主题,并在KDE设置中启用 oxygen-gtk ,使GTK窗口看起来类似于Oxygen.一方面,它确实看起来更接近氧气:

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:

但是,另一方面,我们已经看到了一些细微的差别:只读的行编辑变为灰色,聚焦的按钮仍未突出显示,等等.不幸的是,当尝试将此技术应用于更复杂的小部件时,会出现更多的工件(尤其是在组合框和微调框上):

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):

因此,这种技术似乎不能成为一个完整的解决方案,但在简单的情况下仍然非常有用.

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

推荐答案

氧气是KDE的一部分,因此可以在其中找到它.这不是一个独立的主题.您不能针对Qt 5构建KDE,这不受支持. KDE的下一个主要版本(KDE 5)将使用Qt 5.

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.

所以现在,您绝对无能为力.如果您希望您的应用程序在KDE 4中看起来和表现良好,请使用Qt 4.

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.

这篇关于原生KDE寻找Qt 5应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆