Change Qt5 application style with qt5ct
Qt is one of the most used toolkit to create cross platform GUI applications. It runs on wide range of hardware platform from embedded devices to modern PC without significant change in the main code.
Qt4 based application style could be changed easily by qtconfig-qt4 tool, even by editing the Trolltech.conf file, but there is no such utility to change Qt5 theme, change qt5 widget style or fonts style.
It’s easy to manage Qt5 application style in Qt integrated desktop like KDE, LXQt or Razor-Qt. But a little harder in other desktop like GNOME, Cinnamon, MATE, XFCE or LXDE.
So qt5ct is here to solve the problem, you could use qt5ct to change Qt5 based application style, Qt5 icon theme, Qt5 font style. Even customize the whole widget style with custom Qt style sheet, the qss files.
Qt5ct could use qt5 gtk theme, KDE breeze theme, the fusion theme, QtCurve theme and many more. Each style could be customized further by changing the color schema.
Qt5ct is not available as official binary package in mainline GNU/Linux distributions, but archlinux have a AUR package for it and Ubuntu have a PPA for qt5ct. So if you are running Ubuntu or any Ubuntu derivative like Linux Mint etc. etc. you could install it from the PPA.
It’s possible to compile it from source, the qt5ct latest source code is available at sourceforge, grab the letest release from there.
I’m here going to install it from source on a Debian testing system. So this compilation guide will be almost same for any Debian derivative including Ubuntu, Linux Mint, Kali Linux etc. etc.
- Installing build time dependencies and header files
sudo apt-get install build-essential qt5-qmake qtchooser qtbase5-dev libqt5svg5-dev libpng12-dev qtbase5-dev-tools qttools5-dev-tools qtbase5-private-dev
- Download the qt5ct source code from the above sorceforge, your download mirror could be different.
wget -c jaist.dl.sourceforge.net/project/qt5ct/qt5ct-0.21.tar.bz2
- Now extract the archive and start building it.
tar -xf qt5ct-0.21.tar.bz2
make -j 4
sudo make install
Now installation is finished, give qt5ct a test run,
cd ~/qt5ct-0.21/ ./test.sh
Qt5ct appearance settings >
Testing and setting up qt5ct
To test some Qt5 application with qt5ct rub the application from the command line with the QT_QPA_PLATFORMTHEME environment variable. First run qt5ct and then start the Qt5 application of your choice
EasyPaint is a simple Qt5 based image editor. Now change widget style, font style, icon theme etc. etc. by the qt5ct tool. If it is working make it permanent by exporting the correct environment variable when starting a X11 session.
Crete a file 100-qt5ct under the /etc/X11/Xsession.d/ folder with your favorite text editor
sudo nano /etc/X11/Xsession.d/101-qt
and put the configuration bellow there.
Now log out and log in again to take the changes effect.
I tested it on Debian stretch(testing), running standalone openbox, compton X11 compositor and some Qt only apps, qt5ct working very fine.
It’s straight forward to change Qt5 widget style, font style, icon theme with qt5ct. Hope very soon qt5ct will be available in the software repository of all mainline GNU/Linux distributions.
If you have any suggestion or question, just leave a comment, also don’t forget to share this with friends.