Bug 821062 - Pure Qt applications can't use KDE styles outside of KDE
Pure Qt applications can't use KDE styles outside of KDE
Product: Fedora
Classification: Fedora
Component: kde-settings (Show other bugs)
x86_64 Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Rex Dieter
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2012-05-11 14:02 EDT by Alec Moskvin
Modified: 2012-07-11 14:05 EDT (History)
9 users (show)

See Also:
Fixed In Version: qt-4.8-14
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-07-11 14:05:36 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Alec Moskvin 2012-05-11 14:02:04 EDT
Description of problem:
When running non-KDE Qt applications outside of KDE, instead of using the default KDE style (like KDE applications do), they instead use an ugly "Windows" style.

Version-Release number of selected component (if applicable):
Fedora 17, Qt 4.8.1, KDE 4.8.3

How reproducible:

Steps to Reproduce:
1. Install Fedora 17 KDE spin
2. yum install openbox qt-config
3. Start an OpenBox session
4. Run qtconfig-qt4
Actual results:
The Qt Config window's widget style is ugly. Notice that "Oxygen" is not that in the GUI Style dropdown. (KDE applications will use the default Oxygen style, however.)

Expected results:
$ QT_PLUGIN_PATH=/usr/lib64/kde4/plugins qtconfig-qt4

Now the style is still set to "Desktop Settings (Default)", but it's using the Oxygen style. The Oxygen theme is also listed in the dropdown.

Additional info:
Gentoo solves it by adding a QT_PLUGIN_PATH entry to the global environment when KDE is installed:
$ grep -r ^QT_PLUGIN_PATH /etc/env.d/

OpenSuSE does it somehow differently, without setting QT_PLUGIN_PATH. Outside of KDE, the default style is "Plastique" for both KDE and non-KDE applications (and Oxygen is in qtconfig's dropdown).
Comment 1 Rex Dieter 2012-05-11 14:33:09 EDT
We purposely do it this way now.  We used to unconditionally set QT_PLUGIN_PATH via various methods even outside of kde, but that ended up with bad side-effects in some situations.
Comment 2 Rex Dieter 2012-05-11 14:40:53 EDT
For some background, see bug #704840 , similar to this.
Comment 3 Alec Moskvin 2012-05-11 16:22:50 EDT
I read the linked bug, but I don't understand the problem - what are the "bad side-effects"? If KDE already sets QT_PLUGIN_PATH, why is it a problem outside of it?

Comment 4 Rex Dieter 2012-05-12 21:33:07 EDT
One of the bad side effects was that the kde platform plugin would load unconditionally.
Comment 5 Kevin Kofler 2012-05-13 09:17:41 EDT
Normally, you're expected to use the GTK+ (QGtkStyle) style outside of KDE, not the Oxygen style.
Comment 6 Rex Dieter 2012-05-14 15:55:55 EDT
One side-effect I recall was that kde4 platform loading in non-kde sessions, and testing just now on f17 with gnome shell, pure qt applications behave the same whether or not I set
export QT_PLUGINS_PATH=/usr/lib64/kde4/plugins
so I'm tempted to conclude that issue is no longer a problem.

Anyone remember other reasons?  If not, perhaps we can consider re-enabling this.
Comment 7 Ngo Than 2012-05-16 08:25:39 EDT
imo we should move this following codes from startkde into /etc/profile.d/kde.sh

# Set the path for Qt plugins provided by KDE
QT_PLUGIN_PATH=${QT_PLUGIN_PATH+$QT_PLUGIN_PATH:}`kde4-config --path qtplugins`

# hack in multilib support
if ! echo ${QT_PLUGIN_PATH} | /bin/grep -q /usr/lib/kde4/plugins ; then

this change will allow qt apps to use kde styles outside/inside KDE.
Comment 8 Rex Dieter 2012-05-16 09:49:26 EDT
We used to do that, but running kde4-config like that slowed down non-kde logins by several seconds, so that approach was reverted.

We then opted to patch code
Comment 9 Rex Dieter 2012-05-16 09:51:29 EDT
See bug #498809
Comment 10 Rex Dieter 2012-05-16 09:53:42 EDT
Here's a link to the qt patch we'd used for awhile, it should still work (may need to be rediffed against current sources):
Comment 11 Rex Dieter 2012-05-16 09:56:40 EDT
(sorry for the spam), so that qt patch along with a kde.sh snippet for *just* multilib (ie, with no kde4-config call):

# hack in multilib support
if ! echo ${QT_PLUGIN_PATH} | /bin/grep -q /usr/lib/kde4/plugins ; then

should then get us all that we want (I think)
Comment 12 Alec Moskvin 2012-05-24 10:27:05 EDT
So... can this be fixed then? :)
Comment 13 Rex Dieter 2012-05-24 10:52:17 EDT
koji build:

* Wed May 16 2012 Rex Dieter <rdieter@fedoraproject.org> 4.8-14
- Pure Qt applications can't use KDE styles outside of KDE (#821062)

Try it out, I'll work to submit this to updates shortly.
Comment 14 Alec Moskvin 2012-05-25 12:06:03 EDT
I've tested it, and it works great.

Unfortunately, in the process I learned what you mean by "kde4 platform loading" - if I open a file dialog, it starts 4 KDE processes :(
Comment 15 Rex Dieter 2012-05-25 13:13:51 EDT
I didn't experience that in my own testing.  Which app(s) did you use as test cases?

When you mentoined other distros have this "feature", did they also have this same side-effect?
Comment 16 Alec Moskvin 2012-05-25 17:02:03 EDT
I opened Qt Configuration, and on hit "Browse..." on the bottom of the "Printers" tab, and it resulted in the KDE-style browse dialog (rather than the plain one).

There is a possibility that it's due to something I did... I'll try a clean install in a VM when I have time.
Comment 17 Kevin Kofler 2012-05-25 18:05:18 EDT
Setting the style to Oxygen will make Oxygen load into all Qt processes, which in turn loads KDE libraries, which in turn override the dialogs. This is more or less expected.

(I assume Rex only set the plugin path, which by itself won't cause this effect (or at least shouldn't), not set the style to Oxygen, right Rex?)
Comment 18 Rex Dieter 2012-05-25 18:38:24 EDT
I tested in gnome3 and xfce manually setting plugin path prior to running a handful of qt only apps
Comment 19 Alec Moskvin 2012-05-25 19:46:09 EDT
Kevin is right - if the theme is not Oxygen, KDE processes are not started.

However, Oxygen does become the "Desktop Settings (Default)" theme, in an Openbox session with the KDE Spin.

Certainly *I* don't have a problem with that - I think that's great. I'm just laying out the facts so that no one is surprised a week or two later :)
Comment 20 Rex Dieter 2012-07-11 14:05:36 EDT
marking as fixed.  with all the caveats mentioned in the last few comments.

Note You need to log in before you can comment on or make changes to this bug.