Bug 702493 - Qt Applications don't pick up gtk theme
Qt Applications don't pick up gtk theme
Product: Fedora
Classification: Fedora
Component: qt (Show other bugs)
x86_64 Linux
unspecified Severity medium
: ---
: ---
Assigned To: Ngo Than
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2011-05-05 16:30 EDT by hannes
Modified: 2013-10-04 08:27 EDT (History)
15 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-01-12 10:08:00 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Screenshots of Xfce and Qt applications (259.74 KB, image/png)
2011-06-24 08:30 EDT, hannes
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
Qt Bug Tracker QTBUG-21294 None None None Never
Qt Bug Tracker QTBUG-5545 None None None Never

  None (edit)
Description hannes 2011-05-05 16:30:10 EDT
Description of problem:
I am using xfce and all qt application recently stopped to apply the gtk theme and fall back to a basic qt style. During the startup they print out the message:
QGtkStyle was unable to detect the current GTK+ theme.

I asked on #qt and they provided me with a little patch, namely to remove line 511 in qgtkstyle_p.cpp:

509         if (themeName.isEmpty()) {
510             qWarning("QGtkStyle was unable to detect the current GTK+ theme.");
511             return;

I don't know if this patch would be applicable but it would really enhance the usability of Qt in Xfce, because afaik only Xfce is affected by this.

Version-Release number of selected component (if applicable):
rpm -qa | grep qt

Expected results:

Additional info:
Comment 1 Reartes Guillermo 2011-05-14 16:15:25 EDT
I use KDE and gtk applications no longer use qt/kde themes.
In F13/F14 gtk apps looked like kde/qt ones.
In F15 gtk apps are gtk on kde. I noticed with Firefox, sadly i never reported it because i was busy with other bug-reports.
Comment 2 Kevin Kofler 2011-05-14 16:53:55 EDT
Re comment #1, this is completely unrelated to this bug report (which is about Qt applications not picking up the correct GTK+ theme, not the opposite), and not a bug at all.

Many GTK+ applications in F15 are now gtk3. The oxygen-gtk currently packaged in Fedora 15 is only for gtk2. A GTK+ 3 port is under development, but there is no stable release yet, and it isn't packaged in Fedora yet. In addition, overriding the systemwide default gtk3 theme for KDE Plasma sessions (through kcm-gtk) is not implemented yet either. So you're getting the Adwaita gtk3 theme, which is the only stable one at this time.
Comment 3 Julian Sikorski 2011-05-15 10:20:18 EDT
I am getting mixed experience. Some applications do pick Adwaita (linguist-qt4), some do not (qmc2, available in RPM Fusion). I am not sure what the difference is.
Comment 4 hannes 2011-05-21 07:05:57 EDT
Could someone who is in charge, please leave a comment on this bug?
Comment 5 Rex Dieter 2011-06-03 11:12:54 EDT
I've got some odd/interesting results testing in gnome3 today too:

ALT-2: yakuake  => kde/oxygen themed
in yakuake, run konsole => qgtkstyle'd
quit yakuake, start again => qgtkstyle'd

Comment 6 Rex Dieter 2011-06-03 11:58:22 EDT
testing apps on xfce, launched via ALT-F2:

konsole -> qgtkstyle
qtconfig-qt4 -> qgtkstyle
linguist-qt4 -> qgtkstyle
qmc2-sdlmess -> mixed qgtkstyle and something else?, maybe this app isn't using standard widgets?

anyone experiencing this, can you provide details on which apps your using and see this please?
Comment 7 Julian Sikorski 2011-06-03 18:16:33 EDT
There was a style-related bug in qmc2 which is fixed in svn. I can make a package if you would like to try.
Comment 8 hannes 2011-06-24 06:49:48 EDT
I use various qt apps in Xfce. So far they are all affected by this.

- texmakerx
- vlc
- recoll
- qtconfig-qt4
Comment 9 Christoph Wickert 2011-06-24 07:39:39 EDT
What do the follfing commands return?

$ grep ThemeName ~/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml 
$ grep style ~/.config/Trolltech.conf
Comment 10 hannes 2011-06-24 07:43:06 EDT
$grep ThemeName ~/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml 
    <property name="ThemeName" type="string" value="egtk-git"/>
    <property name="IconThemeName" type="string" value="elementary-mono-dark"/>
    <property name="SoundThemeName" type="string" value="default"/>
    <property name="KeyThemeName" type="string" value=""/>
    <property name="CursorThemeName" type="string" value=""/>

$grep style ~/.config/Trolltech.conf
usr\lib\kde4\plugins\styles\oxygen.so=40503, 0, i386 linux g++-4 full-config, 2009-12-03T18:30:02
com.trolltech.Qt.QStyleFactoryInterface%3A\usr\lib\kde4\plugins\styles\oxygen.so=2009-12-03T18:30:02, Oxygen
usr\lib\kde4\plugins\styles\oxygen.so=40601, 0, i386 linux g++-4 full-config, 2010-02-10T16:51:44
usr\lib\kde4\kcm_style.so=40602, 0, i386 linux g++-4 full-config, 2010-02-26T08:45:17
com.trolltech.Qt.QStyleFactoryInterface%3A\usr\lib\kde4\plugins\styles\oxygen.so=2010-02-10T16:51:44, Oxygen

The egtk-git version has a gtk-3.0 version. I don't know if this is depending on the used gtk-theme.
Comment 11 Rex Dieter 2011-06-24 07:52:08 EDT
$grep style ~/.config/Trolltech.conf
usr\lib\kde4\plugins\styles\oxygen.so=40503, 0, i386 linux g++-4 full-config,

Means, you've configured oxygen at some point.

Try removing ~/.config/Trolltech.conf and see what happens.
Comment 12 Christoph Wickert 2011-06-24 07:53:13 EDT
Sorry, I should have let you grep for ^style instead of style to filter out the noise.

But as you can see you have no have no style selected for qt, otherwise it would return

grep ^style ~/.config/Trolltech.conf 

Please set the style to GTK+ with qtconfig-qt4 and make sure you have either /usr/share/themes/egtk-git/gtk-2.0/gtkrc or ~/.themes/egtk-git/gtk-2.0/gtkrc.
Comment 13 hannes 2011-06-24 08:06:00 EDT
Alright removed the .conf file and set GTK+ with qtconfig-qt4. 
$ grep ^style ~/.config/Trolltech.conf

Also the gtkrc files are there:
ls -al  ~/.themes/egtk-git/gtk-2.0/
total 84
drwxrwxr-x 9 johannes johannes  4096 Jun  3 09:22 .
drwxrwxr-x 8 johannes johannes  4096 May 25 18:42 ..
drwxrwxr-x 4 johannes johannes  4096 Jun 20 21:43 Apps
drwxrwxr-x 2 johannes johannes  4096 Jun 20 21:36 Button
-rw-rw-r-- 1 johannes johannes 23038 Jun  3 09:22 gtkrc
drwxrwxr-x 2 johannes johannes  4096 Jun 20 21:36 Handle
drwxrwxr-x 2 johannes johannes  4096 Jun 20 21:36 Icons
drwxrwxr-x 4 johannes johannes  4096 Jun 20 21:36 nautilus
-rw-r--r-- 1 johannes johannes 22776 Apr  7 20:24 old_gtkrc
drwxrwxr-x 2 johannes johannes  4096 Jun 20 21:36 Range
drwxrwxr-x 2 johannes johannes  4096 Jun 20 21:36 Sidebar

But the appearance of any newly started qt program looks like before and gives the exact same message as before "QGtkStyle was unable to detect the current GTK+ theme.".

btw thanks for your interest
Comment 14 Christoph Wickert 2011-06-24 08:20:33 EDT
No problem, you are welcome.

Can you try another GTK theme for a moment, say Adwaita?
Comment 15 hannes 2011-06-24 08:30:01 EDT
Created attachment 509744 [details]
Screenshots of Xfce and Qt applications
Comment 16 hannes 2011-06-24 08:30:27 EDT
Makes no difference as far as I can see.
Comment 17 techtonik 2011-09-05 10:16:57 EDT
I've got 'QGtkStyle was unable to detect the current GTK+ theme.' and a lot of messages like below when running Python Qt application:

(process:7350): Gtk-CRITICAL **: IA__gtk_icon_theme_get_for_screen: assertion `GDK_IS_SCREEN (screen)' failed

(process:7350): GnomeUI-CRITICAL **: gnome_icon_lookup: assertion `GTK_IS_ICON_THEME (icon_theme)' failed

Is it possible to fix that for everybody?
Comment 18 techtonik 2011-09-05 10:17:59 EDT
Yes, my config is Fedora 15 with what I believe is called Gnome 3.
Comment 19 Kevin Kofler 2011-09-05 10:21:43 EDT
Hmmm, I guess Qt is still looking in GConf for the GTK+ theme to use, but GNOME 3 is using GSettings with dconf to store the setting.

Either Qt needs to look in dconf, or (probably the better idea), it should be using the xsettings setting which GNOME sets, which would also allow reacting to theme changes on the fly (if QGtkStyle is able to do that in the first place).
Comment 20 Kevin Kofler 2011-09-05 10:22:10 EDT
Can somebody report this to upstream Nokia?
Comment 21 hannes 2011-09-05 10:27:58 EDT
That's not only a problem of Gnome but also other DEs so I don't know if this approach will cover other DEs as well. Also I think upstreaming of a bug is mostly the duty of a package maintainer.

Comment 22 techtonik 2011-09-05 11:31:05 EDT
(In reply to comment #20)
> Can somebody report this to upstream Nokia?

Done. https://bugreports.qt.nokia.com/browse/QTBUG-21294
Comment 23 hannes 2011-09-06 02:26:21 EDT
Could someone please add to the upstream report that this is _not_ only an issue in Gnome3?
Comment 24 techtonik 2011-09-06 02:40:48 EDT
(In reply to comment #23)
> Could someone please add to the upstream report that this is _not_ only an
> issue in Gnome3?

It is not hard of course, but it would be better added by a person who experiences the problem and can answer the questions. I am not too excited about being a proxy between bugtrackers, and registering account on https://bugreports.qt.nokia.com/ is not harder than on https://bugzilla.redhat.com/
Comment 25 hannes 2011-09-06 07:50:16 EDT
This request wasn't addressed at you techtonik but rather to the qt maintainer(s). Not that I, as maintainer of various other packages, hesitate to upstream a bug but imho it's one of the responsibilities of the package maintainer to upstream bugs. [1]
I do it if I couldn't solve a bug and I expect it from others as well.

[1] http://fedoraproject.org/wiki/Package_maintainer_responsibilities#Deal_with_reported_bugs_in_a_timely_manner
Comment 26 Kevin Kofler 2011-09-06 10:44:30 EDT
I'm a comaintainer for the Qt package. I see my role as a maintainer, not as a messenger. If you want to tell the Nokia Qt developers something, then tell them, not us. I don't see how playing "Stille Post" helps anybody, it's much more effective to talk to the intended people directly.
Comment 27 hannes 2011-09-06 11:04:57 EDT
I don't want you to play "Stille Post", I just want the bug to be fixed actually. If it is fixed for all DEs by simply checking which theme Gnome uses, it's fine but otherwise the bug isn't fixed for many users.

Also I don't see how this scales when every regular user needs an upstream bug tracker account. If your reasoning would really apply we won't need this bugzilla because most of the bugs should be better filed upstream.
Comment 28 hannes 2011-11-28 15:05:01 EST
Seems that also reporting bugs upstream doesn't seem to help getting them fixed. Is there any additional information needed?
Comment 29 hannes 2012-04-06 04:10:42 EDT
The following workaround works for me, don't know if we could incorporate it. I doubt.
Comment 30 Kevin Kofler 2012-04-06 07:47:00 EDT
That doesn't look like a good solution indeed.

Qt's QGtkStyle needs to either look in xsettings (Net/ThemeName) itself or just let GTK+ handle the theme selection itself (it will use xsettings just fine). The workaround looks as if QGtkStyle were looking only in the GTK2_RC_FILES, which is very broken.
Comment 31 Massimiliano 2012-06-29 19:43:32 EDT
I have the same issue with F17 and vlc (gnome-shell and cinnamon as DE). When launched from terminal: QGtkStyle was unable to detect the current GTK  theme.

This bug seems related to:

First workaround (probably the weakest):
$ export GTK2_RC_FILES="/etc/gtk-2.0/gtkrc"
$ vlc

Second workaround (don't needs other packages):
$ gconftool-2 --set --type string /desktop/gnome/interface/gtk_theme Adwaita

Third workaround (probably the best):
# yum install libgnomeui

All these workarounds work for me. Note: the third workaround needs to restart the environment.

Hope this helps.
Comment 32 Rex Dieter 2012-06-29 20:46:43 EDT
This gives a hint that adding a method to use xsettings to query current gtk theme may be one way to help fix this.
Comment 33 Sergio 2012-09-30 09:29:42 EDT
This would be a bug now more than ever because even GNOME doesn't use gconf any more to set the interface (uses gsettings).
So I was about to look for and eventually open a bug report so it would check xfsettingsd settings instead (or something more general).

https://bugreports.qt-project.org/browse/QTBUG-5545 has just been marked as resolved for qt 5.0.0 beta 2
I just didn't understand the reason nor do I know if they just dropped the feature etc.
Does anyone know if that 'fix' will make it work with Xfce?
Maybe someone has an account at qt bugs and could ask?

TBH, if we use a standalone window manager, with ~/.gtkrc-2.0 and ~/.config/gtk-3.0/settings.ini qt doesn't pick up the style either so the best solution would be some that would include also these files.
Comment 34 Kevin Kofler 2012-09-30 10:45:22 EDT
Upstream says: "We have simply removed the sanity check at startup. It should be safe to ignore this as the cause for the sanity check (gtk qt theme) is no longer supported by modern linux distributions." I think we can do the same in our Qt 4 builds, we stopped shipping gtk-qt-engine years ago!
Comment 35 Fedora Update System 2013-01-05 15:10:35 EST
qt-4.8.4-4.fc17 has been submitted as an update for Fedora 17.
Comment 36 Fedora Update System 2013-01-05 15:10:42 EST
qt-4.8.4-5.fc18 has been submitted as an update for Fedora 18.
Comment 37 Fedora Update System 2013-01-05 15:11:23 EST
qt-4.8.4-5.fc16 has been submitted as an update for Fedora 16.
Comment 38 Fedora Update System 2013-01-05 15:11:23 EST
qt-4.8.4-5.fc17 has been submitted as an update for Fedora 17.
Comment 39 Fedora Update System 2013-01-06 16:53:35 EST
Package qt-4.8.4-5.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing qt-4.8.4-5.fc18'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).
Comment 40 Fedora Update System 2013-01-12 10:08:04 EST
qt-4.8.4-6.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 41 Fedora Update System 2013-01-22 20:39:49 EST
qt-4.8.4-6.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 42 Fedora Update System 2013-01-24 16:57:31 EST
qt-4.8.4-6.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 43 Red Hat Bugzilla 2013-10-03 20:20:50 EDT
Removing external tracker bug with the id '21294' as it is not valid for this tracker
Comment 44 Red Hat Bugzilla 2013-10-03 20:22:01 EDT
Removing external tracker bug with the id '5545' as it is not valid for this tracker

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