Uniform look for QT and GTK apps
From ArchWiki
| i18n |
|---|
| English |
| 简体中文 |
Contents |
[edit] Introduction
Qt- and GTK+ -based programs both use a different widget toolkit to render the graphical user interface. Each come with different themes, styles and icon sets by default, among other things, so the "look and feel" differ significantly. This article will help you make your Qt and GTK+ applications look similar for a more streamlined and "integrated" desktop experience.
"Qt (pronounced "cute") is a cross-platform application development framework, widely used for the development of GUI programs (in which case it is known as a Widget toolkit), and also used for developing non-GUI programs such as console tools and servers."
- Theme - Collection of a style, an icon theme and a colour theme.
- Style - Graphical layout; look.
- Icon Theme - Set of global icons.
- Colour Theme - Set of global colours that are used in conjunction with the style.
[edit] Styles
There are widget style sets available for the purpose of integration, where builds are written and provided for both Qt and GTK+, all major versions included. With these, you can have one look for all applications regardless of the toolkit they had been written with.
[edit] QtCurve
Available for qt4 (kde4), qt3 (kde3), gtk2, and gtk1 in the [community] repository, this highly-configurable style is the most popular all-arounder. It has many controls for various options, ranging from the appearance of buttons to the shape of sliders. You can install all of them.
pacman -Sy qtcurve-gtk1 qtcurve-gtk2 qtcurve-kde3 qtcurve-kde4
To change the Qt version 3 style in KDE version 3:
Control Center (kcontrol) --> Appearance & Themes --> Style --> Widget Style = QtCurve
To change the GTK+ version 2 style in KDE version 3:
pacman -Sy gtk-chtheme
Run it and you will be able to make your choice. You can also change the fonts. Please note that any open application must be restarted in order to view the changes. Alternatively, you can do the same with an engine, mentioned further below.
[edit] Others
Similar style sets are those that look like each other - written and provided for both Qt and GTK+ - but are not necessarily from the same developers. You may have to do some minor tweaking to make them look the same. Below is a list:
- klearlooks (qt3); clearlooks (gtk2)
[edit] Theme Engines
A Theme Engine can be thought of as a thin layer API which translates themes (excluding icons) between one or more toolkits. These engines add some extra code in the process and it is arguable that this kind of a solution is not as elegant and optimal as using native styles.
[edit] GTK-QT-Engine
This one is for use by GTK+ applications running in KDE, which basically means this is for KDE. It applies all Qt settings (styles, fonts, not icons though) to the GTK+ applications and uses the style plug-ins directly. Please note that there are rendering issues with some Qt styles.
pacman -Sy gtk-qt-engine
You can access it from:
Control Center (kcontrol) --> Appearance & Themes --> GTK Styles and Fonts
If you want to remove it entirely and every trace of it, you should delete the following files:
- ~/.gtkrc2.0-kde
- ~/.kde/env/gtk-qt-engine.rc.sh
- ~/gtk-qt-engine.rc
[edit] MetaTheme
The metatheme engine is designed as a thin layer between toolkits, creating a unified API by which each theme engine can draw. The result is that every application uses the same code for drawing, making the appearance same across different applications. This engine supports the GTK2, QT/KDE, and Java toolkits.
pacman -Sy metatheme
To install..
metatheme-install
To configure settings..
mt-config
To uninstall..
metatheme-install -u
[edit] Other Tricks
[edit] KDE file dialogs for GTK2 apps
KGtk is a wrapper script that LD_PRELOAD to force KDE file dialogs (open, save, etc) in GTK2 apps. If you use KDE and prefer it's file dialogs over GTK's then you can install kgtk from AUR. Once installed you can run GTK2 applications with kgtk-wrapper in 2 ways (using gimp in the examples).
Calling kgtk-wrapper directly and using the GTK2 binary as an arguement
/usr/local/bin/kgtk-wrapper gimp
OR
Creating a symbolic link to kgtk using the name of the GTK2 binary. Then you can run /usr/local/bin/gimp when you want to run gimp with KDE dialogs.
ln -s /usr/local/bin/kgtk-wrapper /usr/local/bin/gimp /usr/local/bin/gimp
[edit] aMSN GTK or KDE dialogs
aMSN's TK file dialogs are plain looking but no fear there is a plugin that will allow you to use GTK or KDE file dialogs to match your desktop. You can find the plugin on aMSN's Plugin Page
[edit] Troubleshooting
[edit] How do I set styles for each toolkit?
You can use the following methods to change the theme used in each environment.
[edit] KDE3 and QT3 styles
- Control Center (kcontrol) --> Appearance & Themes --> Style --> Widget Style
- kde-config --style [name of style]
- /opt/qt/bin/qtconfig
[edit] QT4 styles
- /usr/bin/qtconfig
[edit] GTK2 styles
- gtk-chtheme
- gtk2_prefs
- switch2 (gtk-theme-switch2 package)
[edit] GTK1 styles
- switch (gtk-theme-switch package)
[edit] Themes not working in GTK apps
If the style or theme engine you setup isn't showing in your GTK apps then it's likely your GTK settings files aren't being loaded for some reason. You can check where your system expects to find these files by doing the following..
export | grep gtk
Usually the expected files should be ~/.gtkrc for GTK1, ~/.gtkrc2.0 or ~/.gtkrc2.0-kde for GTK2
Newer versions of gtk-qt-engine use ~/.gtkrc2.0-kde and set the export variable in ~/.kde/env/gtk-qt-engine.rc.sh If you recently removed gtk-qt-engine and are trying to set a GTK theme then you must remove ~/.kde/env/gtk-qt-engine.rc.sh and reboot. Doing this will ensure that GTK looks for it's settings in the standard ~/.gtkrc2.0 instead of ~/.gtkrc2.0-kde