Bug 168200

Summary: Incorrect color scheme in Qt4 applications, running in KDE4 environment
Product: [Unmaintained] kdelibs Reporter: Dmitry Nezhevenko <dion>
Component: qtAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED UPSTREAM    
Severity: normal CC: andresbajotierra, armin, bugzilla, echidnaman, federico.lox, g4mba5, gio.grifis, godutchnow, igor.poboiko, kde, kojot350, mail, ogoffart, olivier.roncali, piemonkey, pierre, rdieter, spatz
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: screenshot
screenshot showing systemsettings, qtconfig, assistant and designer together
qt4 vs kde4 gui elements
colorbug.png
diff against Qt 4.4.3

Description Dmitry Nezhevenko 2008-08-03 13:08:02 UTC
Version:            (using KDE 4.1.0)
Installed from:    Debian testing/unstable Packages
Compiler:          4.3 
OS:                Linux

There is strange behaviour with Qt4 (non-KDE) applications, launched from KDE4 environment. They automatically gets KDE theme (that's correct), however not all color scheme settings are applied to them. For example QTextBrowser and QTextEdit background is always white. 

For example in qtconfig-qt4 left widget (with description) has white background. I can change it by pressing "Tune palette button and adjusting color for "Base" role. However after restarting qtconfig-qt4 it, this widget became white again. 

It looks like this is not qtconfig/Qt4 bug, since without KDE4 I can adjust all colors of Qt4 applications without any problems.

Porting application to KDE4 fixes problem too. It's enough to replace creating QApplication instance with KApplication. But as for me, this is ugly hack.
Comment 1 Sergei Andreev 2008-08-03 14:09:29 UTC
Created attachment 26597 [details]
screenshot

Confirm that, for example kopete and qstardict settings
Comment 2 George Kiagiadakis 2008-08-03 15:27:44 UTC
I can confirm that too. It is simple to reproduce. Set the color scheme to "wonton soup" and open qtconfig, qt assistant and qt designer. You will notice that designer gets the correct colors but qtconfig and assistant get the wrong colors. Some colors are changed in assistant and qtconfig, but not all of them!
Comment 3 George Kiagiadakis 2008-08-03 15:29:57 UTC
Created attachment 26599 [details]
screenshot showing systemsettings, qtconfig, assistant and designer together

Notice that qtconfig and assistant have the wrong colors.
Comment 4 Hannes H 2008-08-26 11:52:19 UTC
I can confirm color issues on kde4 vs qt4-only. 

Most color seem to be transformed right (application window, buttons ...), but certain colors are not ("selection", tooltips, progressbars).

I am using kde4.1.0 on FreeBSD. A ML-Thread discussing detail is available here:
http://mail.kde.org/pipermail/kde-freebsd/2008-August/003610.html

A Screenshot demonstrating my issues is also available in the archive:
http://mail.kde.org/pipermail/kde-freebsd/attachments/20080822/746d8762/attachment-0001.jpeg
(note that the window being darker is Kwin-effect, not a color problem)

Thanks for your help!
Comment 5 Maciej Mrozowski 2008-10-01 02:30:21 UTC
Created attachment 27629 [details]
qt4 vs kde4 gui elements

Confirmed - not only colors are not set properly but looks like all QT4 GUI elements are actually larger that KDE4 ones.
Screenshot attached.
Comment 6 Matt Whitlock 2008-10-07 07:53:23 UTC
Created attachment 27726 [details]
colorbug.png

Took me a while to find this bug, but I'm glad it's an issue that has been reported by others.  Throwing my screenshot onto the pile.

Is Qt4 reading the ~/.config/Trolltech.conf file?  I see Palette\active, Palette\disabled, and Palette\inactive in there.  Each contains a long list of hex colors.  Are all of those being set properly by KDE System Settings applet?  Is Qt4 respecting those palettes?  Is this a KDE4 bug (not configuring Qt4's palette appropriately) or a Qt4 bug (not respecting configured palette)?
Comment 7 Federico "Lox" Lucignano 2008-10-26 18:00:30 UTC
I've found a little hack to fix this problem, this is an excerpt from the bug report I've opened on Launchpad:

"After doing some research through strace logs I've found that all Qt4 related apps read ~/.conf/Trolltech.conf a few times during startup and by deleting all the colour-related lines in the [qt] section of this file the problem seems to be solved (of course this 'hack' should be repeated each time modified settings in SystemSettings' colour and style panels are applied or qtconf-qt4 is used).

It's a weird, weird bug IMHO"

Look here (https://bugs.launchpad.net/opensuse/+bug/289540) for more info/attachments.

I've encountered this same bug on all the distros shipping KDE 4.1.2 (Kubuntu 8.10, Mandriva 2009.0 and openSUSE 11.1).
Comment 8 Hannes H 2008-11-06 14:12:57 UTC
I can confirm, the hack fixes the problems.
You need to remove all of the *palette*-lines.

I suppose this KDE writing the wrong lines to the file, or not?
Comment 9 Federico "Lox" Lucignano 2008-11-08 17:41:51 UTC
*** This bug has been confirmed by popular vote. ***
Comment 10 Federico "Lox" Lucignano 2008-11-08 17:50:14 UTC
The small hack I found seems to work in a stable manner, so I'm posting a small tip to automate it since the "Palette" lines keep on coming back at every session login.

Just create a shell script wherever you want (mine is ~/fix_qt4_colors) and paste the following 2 lines into it:

#!/bin/sh
cat ~/.config/Trolltech.conf | grep -v ^Palette > ~/.config/Trolltech.conf

That will filter out the lines charged with messing colors for qt4-only apps and save the result back to Trollech.conf.

Now all you need to do is make the script executable and add it to your session startup through Systemsettings' Autostart module.

P.s.: I know this is a basic procedure but many linux beginners follow the instructions found in bug reports to solve problems.

P.p.s: I'm posting this on Launchpad too.
Comment 11 Hannes H 2008-11-08 17:59:07 UTC
Yeah, that works.
I just hacked around the problem, by removing the lines manually and 
chmod -w ~/.config/Trolltech.conf

I really think this is a KDE-Issue though, so someone should just remove the code that writes KDE's palette to ~/.config/Trolltech.conf . Apperently it isnt necessary anyway.
Comment 12 Pierre Schmitz 2008-11-27 10:59:48 UTC
I can confirm this bug still exists in 4.2 Beta 1. Especially when not using the Oxygen theme this is noticable.
Comment 13 Frozen Fox 2008-12-03 07:27:37 UTC
I have this same problem, however the 'hack' listed above causes as many problems as it fixes for me. 

I use a mix of pure qt4, kde4, and gtk apps. I use a dark self-made blue/black color scheme, QTCurve-kde4, and QTCurve-gtk. I use lxappearance to have gtk apps show up with qtcurve-gtk identically to normal kde4 including fonts and oxygen icons, and kde4 handles the colors. 

Kde4-gtk or whatnot nor gtk-qt-engine work correctly for me, primarily color and font problems. The naked qtcurve-kde4 + lxappearance works perfectly except.. I can have EITHER the pure qt4 app colors show up slightly wrong (some bits of white atop tabs, and white selected items) or the gtk app colors -completely- wrong (-everything- is white-ish) if I use the hack or either of the aformentioned programs. One gets fixed, the other gets messed up. The aforementioned hack does indeed fix pure qt4 apps, but does screw up gtk ones. Unless I've messed something up somewhere, those added lines don't seem to be as unnecessary as suggested above -- they make gtk apps look right.

Since I have less pure qt4 programs that I frequently use and their color problem is minor instead of major, that is the lesser of two evils I deal with.

If anyone has any other ideas or could point me to how I screwed the above up and -can- have both qtcurved gtk and qtcurved pureQT4 fixed simultaneously, I would be most grateful.
Comment 14 Frozen Fox 2008-12-11 15:56:56 UTC
The problem -appears- to be fixed (yay! pure qt, kde, and gtk apps all working together!) in markc's kde4-svn nightly binary build for Arch Linux on Dec. 12, 2008, using the qt package from the same repository titled "qt-snapshot-4.5.0-2008121101". Thank goodness. That was annoying me more than anything else on kde4!
Comment 15 pantsgolem 2008-12-25 17:41:57 UTC
I found it!  It's not a KDE bug at all!  Look at <http://websvn.kde.org/trunk/qt-copy/src/gui/kernel/qapplication_x11.cpp?view=markup> -- the function "kdeColor" (used for a few select color roles, including selectBackground) tries to read "~/.kde/share/config/kdeglobals" for a few select color roles.  On most systems, that's the KDE3 version of the file.

I just downloaded the latest Qt 4.5 snapshot, and it has the problem solved.  I'm working on a patch to backport their fix.  I'll post it here once I've tested it.

(In the meantime, the workaround that doesn't involve constantly re-editing Trolltech.conf is to put the right colors in your KDE kdeglobals file.  Note that you can't just copy the KDE4 version, because the names of the color roles have changed.)
Comment 16 pantsgolem 2008-12-25 20:29:33 UTC
Created attachment 29627 [details]
diff against Qt 4.4.3

Ok, so far so good with this patch.  Feel free to point your distro maintainers this way.

For openSUSE users, I have packages building in my OBS repository at <http://download.opensuse.org/repositories/home:/pantsgolem/>, but the Build Service server is being difficult, so it may be a while before it's available for all versions/arches.
Comment 17 Armin Berres 2008-12-25 20:32:54 UTC
IMO you should try to get this into Qt copy. This is the fastest way to get this reviewed and into the distributions.
I'd mail kde-core-devel@kde.org if I'd be you...

Thanks for the patch btw :-)
Comment 18 Dario Andres 2009-01-07 22:28:58 UTC
Shouldn't this be marked as UPSTREAM as it's a QT bug ?
Comment 19 Igor Poboiko 2009-01-23 10:24:24 UTC
I can confirm this bug, KDE 4.1.4, Qt 4.4.3

When i move ~/.kde4/share/config/kdeglobal to ~/.kde/share/config/kdeglobal, system theme applyes to my qt4-apps

PS sorry for my bad english
Comment 20 Nicolas L. 2009-01-25 13:05:30 UTC
i think this patch should go on qt-copy before closing the bugreport
Comment 21 aapgorilla 2009-01-25 19:17:05 UTC
The patch only seems to fix fonts, not the colour scheme
Comment 22 Giovanni Masucci 2009-01-26 06:46:32 UTC
confirm...colour scheme is still wrong for me... 
Comment 23 Paweł Prażak 2009-02-02 18:52:42 UTC
I confirm.

openSUSE 11.1 x86_64
Qt: 4.4.3
KDE: 4.2.00 (KDE 4.2.0) "release 83.1"
Plasma Workspace: 0.3
x11-video-nvidiaG02, Version: 180.22-4.1
Comment 24 George Kiagiadakis 2009-02-02 19:17:31 UTC
Is this bug reported to Qt software? Is there a patch in qt-copy? Is anybody working on it?
Comment 25 Matt Whitlock 2009-02-03 00:20:27 UTC
(In reply to comment #24)
> Is this bug reported to Qt software? Is there a patch in qt-copy? Is anybody
> working on it?

Please read the comments before you ask a question.  Comment #15 says this bug has already been fixed in Qt 4.5.
Comment 26 Dario Andres 2009-02-10 14:25:33 UTC
*** Bug 183787 has been marked as a duplicate of this bug. ***
Comment 27 aapgorilla 2009-02-10 23:15:14 UTC
(In reply to comment #25)
> (In reply to comment #24)
> > Is this bug reported to Qt software? Is there a patch in qt-copy? Is anybody
> > working on it?
> 
> Please read the comments before you ask a question.  Comment #15 says this bug
> has already been fixed in Qt 4.5.
> 

I upgraded to qt4.5 and the colour scheme is still incorrect
Comment 28 aapgorilla 2009-02-10 23:20:36 UTC
oops sorry disregard that last message I was running qt3config to check; 

The colour scheme actually is correct in qt4 apps 
Comment 29 Dario Andres 2009-02-16 11:17:31 UTC
*** Bug 184487 has been marked as a duplicate of this bug. ***
Comment 30 Jonathan Thomas 2009-02-20 23:01:34 UTC
Qt-copy is now Qt 4.5, so it wouldn't be necessary to add the patch any more.