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. Change the font of the application
Forum Updated to NodeBB v4.3 + New Features

Change the font of the application

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 4.4k Views 2 Watching
  • 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.
  • M Offline
    M Offline
    Mr Gisa
    wrote on last edited by
    #1

    I want to change the application font for everything. In the main file I tried to load a font using QFont and setting it to the QMainWindow with setFont and it works normally, the problem is that if I change the stylesheet of any widget in it like to set the font-weight to bold it requires me to use font-family as well in the stylesheet or it will switch to the default font automatically. If I use the setFont on the QApplication it works better than in QMainWindow, I don't have to specify the font family in the stylesheet, only setting the font-weight to bold will still use the same font, the problem is that the fonts are way bigger than normal.

    How to set the font to the entire application?

    Venkatesh VV 1 Reply Last reply
    0
    • M Mr Gisa

      I want to change the application font for everything. In the main file I tried to load a font using QFont and setting it to the QMainWindow with setFont and it works normally, the problem is that if I change the stylesheet of any widget in it like to set the font-weight to bold it requires me to use font-family as well in the stylesheet or it will switch to the default font automatically. If I use the setFont on the QApplication it works better than in QMainWindow, I don't have to specify the font family in the stylesheet, only setting the font-weight to bold will still use the same font, the problem is that the fonts are way bigger than normal.

      How to set the font to the entire application?

      Venkatesh VV Offline
      Venkatesh VV Offline
      Venkatesh V
      wrote on last edited by
      #2

      @Mr-Gisa

      Hi,

      Maintain common stylesheet string for whole application keep it in common class. that string should contain font family and font width as well. wherever you want to use the stylesheet make use of that string directly so that it avoids writing the styleseet properties multiple time.

      M 1 Reply Last reply
      1
      • Venkatesh VV Venkatesh V

        @Mr-Gisa

        Hi,

        Maintain common stylesheet string for whole application keep it in common class. that string should contain font family and font width as well. wherever you want to use the stylesheet make use of that string directly so that it avoids writing the styleseet properties multiple time.

        M Offline
        M Offline
        Mr Gisa
        wrote on last edited by
        #3

        @Venkatesh-V Instead of doing that isn't it better to use stylesheets already like this?

        * {
            font-family: ...
            font-size: 16px;
        }
        

        I asked about the usage of setFont because it's faster than using CSS, but well...

        JonBJ 1 Reply Last reply
        0
        • M Mr Gisa

          @Venkatesh-V Instead of doing that isn't it better to use stylesheets already like this?

          * {
              font-family: ...
              font-size: 16px;
          }
          

          I asked about the usage of setFont because it's faster than using CSS, but well...

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Mr-Gisa
          Yes, what you have written is the simplest & best way to set the overall font.

          You can assume that the time taken to act on this CSS is "below negligible", so don't worry about speed versus setFont()!

          1 Reply Last reply
          1

          • Login

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