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. Can't change font-style or font-weight for anything other than QPushButton using style sheets?

Can't change font-style or font-weight for anything other than QPushButton using style sheets?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 182 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.
  • CJhaC Offline
    CJhaC Offline
    CJha
    wrote on last edited by
    #1

    Hi, I have been trying to implement :hover and :checked state for different widgets using Style Sheets:

    QPushButton:hover, QPushButton:checked{color: red; font-style: oblique};
    QCheckBox:hover, QCheckBox:checked{color: red; font-style: oblique};
    QRadioButton:hover, QRadioButton:checked{color: red; font-style: oblique};
    QSpinBox:hover{color: red; font-style: oblique};
    QLineEdit:hover{color: red; font-style: oblique};
    

    The change in color appears for all widgets but the change in font-style only appears for QPushButton, why?

    1 Reply Last reply
    0
    • gde23G Offline
      gde23G Offline
      gde23
      wrote on last edited by
      #2

      When only parts of an stylesheet get applied the reason can be, that there is an error in the stylesheet. Then only the top part will be parsed and it stops parsing at the line where the error is. Can you first check if the stylesheet itself is valid?

      CJhaC 1 Reply Last reply
      1
      • gde23G gde23

        When only parts of an stylesheet get applied the reason can be, that there is an error in the stylesheet. Then only the top part will be parsed and it stops parsing at the line where the error is. Can you first check if the stylesheet itself is valid?

        CJhaC Offline
        CJhaC Offline
        CJha
        wrote on last edited by CJha
        #3

        @gde23 Yes, I think it is valid because if it would not be then the change in color: red would not appear for all the widgets. And what I have shown in my question is the entire stylesheet that I am applying.

        mrjjM 1 Reply Last reply
        0
        • CJhaC CJha

          @gde23 Yes, I think it is valid because if it would not be then the change in color: red would not appear for all the widgets. And what I have shown in my question is the entire stylesheet that I am applying.

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

          @CJha
          Hi
          I also fiddle with it for a bit and QLineEdit
          seems to totally ignore font changes.

          The docs says font-style should work for any QWidget that repects QFont but
          clearly, it does not.

          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