PCsuggest

  • Quick tip
  • SECURITY
  • NETWORKING
  • OpenWrt
  • HARDWARE

Change Qt5 application style with qt5ct

Updated - May 16, 2018 by Arnab Satapathi

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.

Qt5 is the latest Qt version, now Qt5 is the de facto standard of  Qt based application development, so many Qt4 based applications also ported to Qt5.Qt5ct qt5 configuration tool

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 or icon theme.

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.

Contents

  • Installing qt5ct
    • Installing from source code
  • Testing and setting up qt5ct
  • Conclusion

Installing qt5ct

UPDATE: Qt5ct is now available on Ubuntu 18.04 LTS and Debian testing repository.

Installing qt5ct is as easy as running a single line of command.

sudo apt-get install qt5ct

Proper environment variable is automatically exported when X11 session started.

Installing from source code

It's possible to compile it from source, the qt5ct latest source code is available at sourceforge, grab the letest release from there.

amazon prime logo
Try AmazonPrime for free
Enjoy free shipping and One-Day delivery, cancel any time.

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.

  1. 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
  2. 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
  3. Now extract the archive and start building it.
    tar -xf qt5ct-0.21.tar.bz2
    cd qt5ct-0.21/
    QT_SELECT=5 qmake
    make -j 4
    sudo make install

Now installation is finished, give qt5ct a test run,

cd ~/qt5ct-0.21/
./test.sh

Qt5ct appearance settings > qtct5 appaerance config

Qt5ct Icon theme settnigs >qt5 change icon theme

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

QT_QPA_PLATFORMTHEME=qt5ct easypaint

qt5 change theme icon

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.

export QT_QPA_PLATFORMTHEME=qt5ct

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 to fix screen tearing and some Qt based apps, qt5ct working very fine.

Conclusion

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.

Filed Under: featured, how to Tagged With: LXQt, Qt, Qt apps

Your comments
  1. Daniyar says

    March 27, 2018

    Hi Arnab for your topic!

    I had Linux Mint with Openbox now after QT update nothing is working. I tried all steps according your suggestions but unfortunately when I try to run qt5ct error appears says Could not resolve property : linearGradient4582 and so on a lot of similar errors.
    Could you advise how to solve the problem.
    Thanks!

    Reply
    • Arnab Satapathi says

      March 28, 2018

      Daniyar, frankly I don't have any idea what's going on, could you provide a sinppet of the error messages?

      It's working fine on my Ubuntu 16.04.4 system, Qt library version is 5.5, it's a bit old though.

      Reply
  2. zorzi says

    March 10, 2018

    Really useful tutorial. So happy my QT apps with XFCE do not look ugly anymore.

    On Debian, I had to install qt5-style-plugins package to get GTK2 style choice in qt5ct.

    Many thanks.

    Reply
  3. Yaroslav says

    March 4, 2018

    I had an issue with Krusader icons after upgrading to Debian 9 using Gnome desktop. I did not want to install all those *-dev packages on my machine to build qt5ct from source. So I created Bitbucket repository to build qt5ct binary package inside Docker container:

    https://bitbucket.org/yarosla/qt5ct-builder/

    Binary .deb package can be downloaded there. It is also quite easy to produce binaries for other Linuxes - just select different base Docker image (need to fork the repo).

    Reply
    • Arnab Satapathi says

      March 4, 2018

      Thanks for the tip, it'll be useful for other too.

      Reply
    • Pcs says

      May 16, 2018

      Krusader 2.7.0 is out, and it improves the situation (icons, etc.) a lot.

      Reply
  4. John Griessen says

    August 26, 2016

    john@toolbench64 [~]sudo apt-get install build-essential qt5-qmake qtchooser qtbase5-dev libqt5svg5-dev libpng12-dev qtbase5-dev-tools qttools5-dev-tools qtbase5-private-dev
    .
    .
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    libpng12-dev : Depends: libpng12-0 (= 1.2.50-2+deb8u2) but 1.2.54-4 is to be installed
    E: Unable to correct problems, you have held broken packages.

    Reply
    • Arnab says

      August 26, 2016

      Hi John, thanks for pointing me out, yes I'm running Debian testing, and all packages are meaningful, also tested on Ubuntu 16.04 with qt5ct 0.24 .

      I'm done with Debian stable and it's confusing dependency problem.

      Reply
  5. Arnab says

    August 15, 2016

    Yeah, you can export the environment variable from wherever you want 🙂

    Reply
  6. ania says

    August 14, 2016

    it works ~/.xinitrc
    export QT_QPA_PLATFORMTHEME=qt5ct

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © PCsuggest.com · All rights reserved.

  • Home
  • About
  • Contact
  • Privacy Policy
  • Sitemap