9

I am using a standalone tiling window manager QTile. In QTile I want to organize my GTK and QT Themes. For GTK theme I used a program named "lzappearance" and it works perfectly fine. But, for Qt I am using a program named as "qt5ct". On the top it is written this application is not configured correctly and when I click on the information button it says: The QT_QPA_PLATFORMTHEME environment variable is not set(required value: qt5ct). Please help and guide me on how to set qt5ct and environment variables.

3 Answers 3

16

I'll answer with a full guide to help the ones who have not gotten this far:

  1. Install qt5ct (sudo pacman -S qt5ct)
  2. You might want to install a Qt theme, that can be done by sudo pacman -S breeze for example.
  3. Edit /etc/environment as root by sudo nano /etc/environment and add the line QT_QPA_PLATFORMTHEME=qt5ct and save.
  4. Log out and in (or reboot)
  5. Now in qt5ct you can change your theme and settings

The important part is adding QT_QPA_PLATFORMTHEME=qt5ct to /etc/environment. This makes the Qt theme redirect to qt5ct.

Also, if you want Adwaita for Qt, (as I just did for myselft) you can install adwaita-qt from AUR. (yay install adwaita-qt) It comes with all the variants (light, dark, high contrast and high contrast inverse)

4
  • Hi, Thanks a lot!! Because of you now I am able to set qt themes in QTile. I digged in the Arch Wiki for qt5ct, environment variables, and the github repo of qt5ct but it did not work.Thanks once again!
    – Anuj Tambe
    Dec 8, 2021 at 13:48
  • 1
    You're welcome, I just went through the same stuff a month ago with Gnome, the documentation is not very good about this. I'm very glad to help.
    – tempacc
    Dec 8, 2021 at 21:17
  • 1
    Can you set it locally instead of globally? For example ~/.config/enviroment.d/my-env.conf works for all the vars expect this one (QT_QPA_PLATFORMTHEME=qt5ct).
    – Scorpion
    Jul 19, 2023 at 18:04
  • @Scorpion sorry, I have no idea
    – tempacc
    Jul 20, 2023 at 19:14
1

tempacc's answer is correct. It works. Thanks for your answer :)

For those interested in a more stable Linux Arch or any other flavors or Linux, I suggest adding this configuration: export QT_QPA_PLATFORMTHEME="qt5ct" into an override configuration file. For example, into this "qt5.conf" override file at: /etc/environment.d/qt5.conf


Below is the same as above. But with details and sources for those interested.

The "environment" file is a core Linux file. Editing any core Linux files is risky to result in an unstable Linux. Simply because, in the future, during Linux periodic updates, any Linux core files may be deleted and replaced. In turn, you risk loosing your valuable configurations. In turn, you risk an increasingly unstable Linux. In turn, you risk spending hours or days searching for the cause of an unstable Linux. To find out that somehow, your configuration was automatically removed.

To resolve this challenge above, I suggest editing a Linux override file. Instead of editing a Linux core file. The main difference between a core file and override file is that, in the future, after the periodic Linux updates, all your override files will likely automatically remain. Thus, a more stable Linux :) Those files are called override because any configuration you add to them will automatically override any core Linux configuration.

According to the Linux community, when possible and when appropriate, it is suggested to always add your configuration to override files

Steps to add the qt5 theme configuration to an override file:

  1. If not already done, create a "environment.d" folder at "/etc/environment.d/qt5.conf". By the way, in the folder name, the ".d" suffix means an override. So double-check that you use the "environment.d" override folder. Not the core "environment" folder.

  2. Inside that "environment.d" folder. Add a "qt5.conf" override file. This "qt5.conf" file could be any other override file name to your liking.

  3. Inside that "qt5.conf" file, add this line: export QT_QPA_PLATFORMTHEME="qt5ct"

  4. Set appropriately the permissions on both the override folder and override file above. If not sure, for your override folder and file, use the exact same permissions as the core folder and file.

  5. For the new configuration to be applied, you might need to reboot your device. Done. Enjoy your more stable Linux :)

Related documentation about Linux configuration overrides at:

https://jmmv.dev/2020/08/config-files-vs-directories.html

___• https://archive.ph/rcXKV

___• https://web.archive.org/web/20230131035142/https://jmmv.dev/2020/08/config-files-vs-directories.html

https://manpages.debian.org/apt/sources.list.5.en.html

___• https://archive.ph/cauJe

___• https://web.archive.org/web/20240206050034/https://manpages.debian.org/bookworm/apt/sources.list.5.en.html

https://www.redhat.com/sysadmin/etc-configuration-directories

___• https://archive.ph/wip/qDg5j

___• https://web.archive.org/web/20240202050823/https://www.redhat.com/sysadmin/etc-configuration-directories

1

I know this is an old question, but this is how I was able to set it dynamically on my Arch machine with multiple DE installed (KDE Plasma and i3) running X11 and having qt5ct installed:

  1. Create an executable script within /etc/X11/xinit/xinitrc.d

  2. An example script:

  #!/bin/sh 
  if [[ $XDG_SESSION_DESKTOP == "i3" ]]; then
     export QT_QPA_PLATFORMTHEME=qt6ct
  fi

Reboot.

1
  • Thanks for contributing and welcome here. For the sole sake of… grumping… I would observe that you set the variable to qt6ct… when… with regards to this not that old question… OP appears to be qt5… ;-)
    – MC68020
    Mar 13 at 0:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .