Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Set Qt theme and font without qt5ct

Set Qt theme and font without qt5ct

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 4.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    deleted174
    wrote on last edited by
    #1

    I use the i3 window manager and the qutebrowser web browser. I'd like to configure my preferred font face and size for Qt5 without using any graphical tools such as qt5ct. In particular, I'd like to use some plain text configuration file so that it can be added to my dotfiles git repository. qt5ct's configuration file is not really meant to be read by humans, so I don't like it. When I used GTK I could edit the ~/.config/gtk-3.0/settings.ini file and add a few lines:

    [Settings] 
    gtk-icon-theme-name = Adwaita 
    gtk-theme-name = Adwaita 
    gtk-font-name = DejaVu Sans 11
    

    Can I do something similar with the Qt5 toolkit? Thanks.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      deleted174
      wrote on last edited by
      #2

      I found out I can create a file called stylesheet.qss with the following content:

      * { font-family "Noto Sans"; font-size: 16pt }
      

      Then I can launch qutebrowser as follows:

      qutebrowser --qt-arg stylesheet /path/to/stylesheet.qss
      

      This solution seems to be specific to qutebrowser only. How can apply my custom stylesheet to all Qt applications?

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        I think that has to be supported by your distro - as far as i know the various ways Qt allows it is pr App. Like qt conf and the parameter you used.

        If qt5ct works, could you use that to find out where it put the files if that tool can
        make it work system-wide ?

        You are on ubuntu ?

        1 Reply Last reply
        1
        • D Offline
          D Offline
          deleted174
          wrote on last edited by
          #4

          I'm on Gentoo.

          mrjjM 1 Reply Last reply
          0
          • D deleted174

            I'm on Gentoo.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @fturco said in Set Qt theme and font without qt5ct:

            Gentoo

            Ok. i dont know that distro but if the qt5ct can do it on that distro , it must mean there is a way to set it somehow.
            You could use strace to see if you can find out how its doing it.

            1 Reply Last reply
            1
            • D Offline
              D Offline
              deleted174
              wrote on last edited by deleted174
              #6

              Unfortunately I don't have any C++/Qt programming skills, so I'm not sure I can understand qt5ct's source code. Learning C++ and Qt is on my todo list anyway, and one of the first real projects could be this one.

              Anyway I found another possible workaround:

              • Configure my favorite fonts in ~/.config/gtk-3.0/settings.ini
              • Add QT_QPA_PLATFORMTHEME="gtk3" to /etc/env.d/99local
              • Run env-update
              • Log out and then log in again

              I guess the dev-qt/qtwidgets needs to be built with the gtk USE flag, but I have not tested it without. Probably the gtk USE flag is needed in order to build the /usr/lib64/qt5/plugins/platformthemes/libqgtk3.so file.

              mrjjM 1 Reply Last reply
              1
              • D deleted174

                Unfortunately I don't have any C++/Qt programming skills, so I'm not sure I can understand qt5ct's source code. Learning C++ and Qt is on my todo list anyway, and one of the first real projects could be this one.

                Anyway I found another possible workaround:

                • Configure my favorite fonts in ~/.config/gtk-3.0/settings.ini
                • Add QT_QPA_PLATFORMTHEME="gtk3" to /etc/env.d/99local
                • Run env-update
                • Log out and then log in again

                I guess the dev-qt/qtwidgets needs to be built with the gtk USE flag, but I have not tested it without. Probably the gtk USE flag is needed in order to build the /usr/lib64/qt5/plugins/platformthemes/libqgtk3.so file.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @fturco
                Hi
                I did mean to just use strace on qt5ct and see if you could see if it would store any interesting files
                in some locations.

                Anyway, you solution seems fine also.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved