Qt4 theme matches GTK2 theme

Pemasu gave me the hint that got me going on this. See previous post about Woof move to 96 dpi:
http://bkhome.org/blog2/?viewDetailed=00190

I found out that Qt4 apps can be made to automatically match the current GTK+2 theme. This is great news, it makes theming for mixed Qt4 and GTK+2 apps so simple.

There are three tricks to it. Firstly, /root/.config/Trolltech.conf is required, with just this in it:

[Qt]
font="DejaVu Sans,10,-1,5,50,0,0,0,0,0"
style=GTK+


Secondly, /etc/rc.d/profile.d/pup_gtk has just this line:

export GTK2_RC_FILES=/root/.gtkrc-2.0

And thirdly, some means is required to append this line to /root/.gtkrc-2.0:

gtk-theme-name="<name of gtk theme>"

Which I have done by modifying the template for the GTK+2 theme-setter 'gtk-chtheme' in Woof, to append that line after running 'gtk-chtheme' executable.

It works great, Qt4 apps like just like the GTK+2 apps.
The downside is that Qt5 uses a different theming system, as does GTK+3. There is currently no method to get GTK+3 apps to match those of GTK+2 apps, which is most unfortunate.

Woof commit:
http://bkhome.org/fossil/woof2.cgi/info/a58616fe5e

Note, the gtk-chtheme template is only applied to a package from a host-distro, not to a PET. So, any existing gtk-chtheme PET will have to be manually modified.
My current Upups use gtk-chtheme DEB package, so OK, but Slacko and my spup14 use the PET from 'common' repo, so I will fix that.


Posted on 29 Mar 2013, 12:23


Comments:

Posted on 29 Mar 2013, 12:55 by BarryK
Qt4 theme match GTK+2
One more thing, a change was required in 3builddistro.

Woof commit:
http://bkhome.org/fossil/woof2.cgi/info/be6f962815

Also, I have fixed the 'gtk-chtheme' PET package, as described above (11K):
http://distro.ibiblio.org/quirky/pet_packages-common/gtk-chtheme-0.3.1-x86.pet



Posted on 30 Mar 2013, 13:36 by disciple
QT5 and GTK2 themes
I haven't got QT5 yet, but from what I've read it still has GTK2 theme support. Perhaps your QT was compiled on a system without GTK2?


Posted on 30 Mar 2013, 15:10 by BarryK
Qt5 supports GTK+2 themes
disciple,
Ah, yes, you are right. Reading this page:
http://blog.qt.digia.com/blog/2012/10/30/cleaning-up-styles-in-qt5-and-adding-fusion/

It seems that Qt5 will still support the "GTK+" style, based on GTK+2 themes. They are not supporting GTK+3 themes yet.

Interesting, Qt seems to be pulling ahead of GTK:
http://www.wikivs.com/wiki/GTK_vs_Qt