Bug 821062 - Pure Qt applications can't use KDE styles outside of KDE
Summary: Pure Qt applications can't use KDE styles outside of KDE
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: kde-settings
Version: 17
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Rex Dieter
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-05-11 18:02 UTC by Alec Moskvin
Modified: 2012-07-11 18:05 UTC (History)
9 users (show)

Fixed In Version: qt-4.8-14
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-07-11 18:05:36 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Alec Moskvin 2012-05-11 18:02:04 UTC
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:
very

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:
Run:
$ 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/
/etc/env.d/77kde:QT_PLUGIN_PATH=/usr/lib64/kde4/plugins

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 18:33:09 UTC
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 18:40:53 UTC
For some background, see bug #704840 , similar to this.

Comment 3 Alec Moskvin 2012-05-11 20:22:50 UTC
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?

$ echo $QT_PLUGIN_PATH
/home/alec/.kde/lib64/kde4/plugins/:/usr/lib64/kde4/plugins/:/usr/lib/kde4/plugins

Comment 4 Rex Dieter 2012-05-13 01:33:07 UTC
One of the bad side effects was that the kde platform plugin would load unconditionally.

Comment 5 Kevin Kofler 2012-05-13 13:17:41 UTC
Normally, you're expected to use the GTK+ (QGtkStyle) style outside of KDE, not the Oxygen style.

Comment 6 Rex Dieter 2012-05-14 19:55:55 UTC
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 Than Ngo 2012-05-16 12:25:39 UTC
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
  QT_PLUGIN_PATH=${QT_PLUGIN_PATH}:/usr/lib/kde4/plugins
fi
export QT_PLUGIN_PATH

this change will allow qt apps to use kde styles outside/inside KDE.

Comment 8 Rex Dieter 2012-05-16 13:49:26 UTC
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 13:51:29 UTC
See bug #498809

Comment 10 Rex Dieter 2012-05-16 13:53:42 UTC
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):
https://bugzilla.redhat.com/attachment.cgi?id=342703&action=diff

Comment 11 Rex Dieter 2012-05-16 13:56:40 UTC
(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
  QT_PLUGIN_PATH=${QT_PLUGIN_PATH}:/usr/lib/kde4/plugins
fi
export QT_PLUGIN_PATH

should then get us all that we want (I think)

Comment 12 Alec Moskvin 2012-05-24 14:27:05 UTC
So... can this be fixed then? :)

Comment 13 Rex Dieter 2012-05-24 14:52:17 UTC
koji build:
http://koji.fedoraproject.org/koji/buildinfo?buildID=319247

%changelog
* Wed May 16 2012 Rex Dieter <rdieter> 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 16:06:03 UTC
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 17:13:51 UTC
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 21:02:03 UTC
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 22:05:18 UTC
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 22:38:24 UTC
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 23:46:09 UTC
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 18:05:36 UTC
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.