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. Qt Style Sheets versus setFont function.
Forum Updated to NodeBB v4.3 + New Features

Qt Style Sheets versus setFont function.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 275 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.
  • C Offline
    C Offline
    cprowesl
    wrote on last edited by
    #1

    Is there any particular reason why the docs for Qt 5.X discourage the intermingling of Style Sheets with the use of the QApplication::setFont function?

    Under the definition of QApplication::setFont the doc states: "Warning: Do not use this function in conjunction with Qt Style Sheets. The font of an application can be customized using the "font" style sheet property. To set a bold font for all QPushButtons, set the application styleSheet() as "QPushButton { font: bold }".

    I would like to know why such usage is discouraged. If it is for convention I may ignore it, but if it is dangerous I may heed it.

    Thanks in advance to anyone who answers.

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

      Hi
      I think It's mostly due to it might not work as expected.
      The SetFont promise to change the font used by any widget in the application but

      if you apply a style sheet to any of the widgets then stylesheet win and calling
      QApplication::setFont seems to have no effect.

      So if you have an applicationwide stylesheet that sets the fonts and combined it with
      QApplication::setFont then the effect is not as expected reading the docs.

      In any case, it does not seem dangerous as I did use it to set a larger font for touch and at the same
      time had stylesheet to tweak the look of several widgets.

      C 1 Reply Last reply
      3
      • mrjjM mrjj

        Hi
        I think It's mostly due to it might not work as expected.
        The SetFont promise to change the font used by any widget in the application but

        if you apply a style sheet to any of the widgets then stylesheet win and calling
        QApplication::setFont seems to have no effect.

        So if you have an applicationwide stylesheet that sets the fonts and combined it with
        QApplication::setFont then the effect is not as expected reading the docs.

        In any case, it does not seem dangerous as I did use it to set a larger font for touch and at the same
        time had stylesheet to tweak the look of several widgets.

        C Offline
        C Offline
        cprowesl
        wrote on last edited by
        #3

        @mrjj Thank you so much. This takes some worry off my mind.

        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