Uniform look for Qt and GTK applications (Italiano)
- 1 Introduzione
- 2 Stile per Qt e GTK+
- 3 How do I set styles for each toolkit?
- 4 Theme Engines
- 5 Other Tricks
- 6 Troubleshooting
I programmi basati su Qt- e GTK+ utilizzano diversi widget toolkit per renderizzare l'interfaccia grafica utente. Ognuno di default è fornito di diversi temi, stili e set di icone così il "look & feel" è significativamente differente. Questo articolo vi aiuterà nel rendere le applicazioni Qt e GTK+ simili tra loro in modo da ottenere un'esperienza desktop più "integrata" e razionale.
"Qt (pronuncia "cute") è un framework di sviluppo applicazioni cross-platform largamente usato per sviluppare sia applicazioni basate su GUI (in questo caso esso è noto come widget toolkit) che applicazioni "non-GUI" come strumenti per console e server."
- Tema - Raccolta di uno stile, un tema di icone e un tema di colori.
- Stile - Layout grafico; look.
- Tema delle icone - Set di icone.
- Tema dei colori - Set di colori usato in associazione allo stile.
Stile per Qt e GTK+
Esistono dei set di stili creati con lo scopo dell'integrazione in quanto scritti e distribuiti per le principali versioni di Qt e GTK+. Con essi è possibile avere un look uniforme per tutte le applicazioni indipendentemente dal toolkit con cui sono state scritte.
Oxygen è lo stile Qt4 preinstallato con KDE4. Esiste anche una versione GTK+ chiamata oxygen-molecule disponibile attraverso AUR. Il suo obbiettivo è quello di fornire un look uniforme alle applicazioni GTK+ quando usate in KDE attraverso gtk-engine-pixbuf, una dipendenza anch'essa disponibile in AUR. Il pacchetto AUR fornisce semplici ma sufficienti informazioni per completare l'installazione. Per informazioni più dettagliate scaricare oxygen-molecule da KDE-look.
Un altro port GTK+ è il pacchetto Template:Package Official. It's primary goal is to ensure visual consistency between gtk and qt-based applications running under kde. A secondary objective is to also have a stand-alone nice looking gtk theme that would behave well on other Desktop Environments. Unlike other attempts made to port the kde oxygen theme to gtk, this attempt does not depend on Qt (via some Qt to Gtk conversion engine), nor does render the widget appearance via hard coded pixmaps, which otherwise breaks everytime some setting is changed in kde.
Available for qt4 (kde4), qt3 (kde3), and gtk2 (gnome) in the [extra] repository, this highly-configurable style is the most popular all-rounder. It has many controls for various options, ranging from the appearance of buttons to the shape of sliders. You can install all of them using pacman.
# pacman -S qtcurve-gtk2 qtcurve-kde3 qtcurve-kde4
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)
How do I set styles for each toolkit?
You can use the following methods to change the theme used in each environment.
- Using KDE3 Control Center (kcontrol):
- --> Appearance & Themes --> Style --> Widget Style
- kde-config --style [name of style]
- Qt Configuration (qt3config | /opt/qt/bin/qtconfig)
- --> Appearance --> Select GUI Style
- Using KDE4 System Settings (/usr/bin/systemsettings)
- --> Common Appearance and Behavior --> Application Appearance --> Style --> Widget Style
- Qt Configuration (/usr/bin/qtconfig)
- --> Appearance --> Select GUI Style
- Template:Package Official (allows you to change style and font of GTK applications in KDE4)
- Template:Package Official (a DE independent configuration tool from the LXDE project, which does not require any other parts of LXDE)
- Template:Package Official (considered a better alternative to switch2)
- Template:Package Official
- Template:Package Official
- Manual configuration
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.
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 -S 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:
Make it work with OpenOffice
Set (as root):
into /etc/profile. In KDE4 systemsettings, make sure "use my KDE style in GTK applications" is selected in Appearance > GTK styles and fonts.
This is a Qt style which intends to make applications blend perfectly into the GNOME desktop environment by using GTK to render all components. To use this style you must have at least GTK+ 2.0 and Qt 4.3, although Qt 4.4 or higher is preferred.
Having trouble making your Qt applications use QGtkStyle?
Qt won't apply QGtkStyle correctly if GTK is using the GTK-QT-Engine. Qt determines whether the GTK-QT-Engine is in use by reading the GTK configuration files listed in the environmental variable GTK2_RC_FILES. If the environmental variable is not set properly, Qt assumes you are using the GTK-QT-Engine, sets QGtkStyle to use the style GTK style Clearlooks, and outputs an error message:
QGtkStyle cannot be used together with the GTK_Qt engine.
Another error you may get after launching qtconfig from a shell and selecting the Gtk+ style is:
QGtkStyle was unable to detect the current GTK+ theme.
Users of Openbox and other non-GNOME environments may encounter this problem. Here is a solution:
- Tell Qt where to look for your GTK configuration file by adding the following to your Template:Filename file:
- To add multiple paths, separate them with colons.
- The $HOME part will expand to be path to your user's home directory. Using the ~ shortcut won't work.
- In Template:Filename you must specify a GTK theme. For example:
Template:File However it seems in some cases those tools insert only an include directive like Template:File which apparently is not recognized by all versions of QGtkStyle. You can hotfix this problem by inserting the gtk-theme-name manually in your .gtkrc-2.0 like above, note however that Gtk2-style-change applications might overwrite that change when you use them.
To choose your GTK theme for QT apps you must run:
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 its 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
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
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
Using custom GTK style
You can use custom styles for specific GTK2 applications. For this, use GTK2_RC_FILES=/path/to/theme/gtk-2.0/gtkrc appname
It will launch firefox with QtCurve theme.
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