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. Setting QFont size for a QGroupBox widgets
Forum Updated to NodeBB v4.3 + New Features

Setting QFont size for a QGroupBox widgets

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

    Hello,

    I would appreciate someone tells me how I can set the font size of the widgets in my qgroupbox widget so all the widgets in it can be affected by the size. I saw this quote from Qt documentation

    "Note: If Qt Style Sheets are used on the same widget as setFont(), style sheets will take precedence if the settings conflict"
    

    I already set stylesheet to the qgroupbox, therefore applying the .setFont() method does not work. It will only work if I deactivate the .setStyleSheet property from the qgroupwidget owing to the standard rule.

    So how can I apply stylesheet and font to the same qwidget such as qgroupbox?

     gbox = QGroupBox()
     gbox.setStylesheet("background-color: blue; color: yellow")
     gbox.setFont(20)
    

    Now, the gbox widget has two properties there, .setStyleSheet and .setFont, the two properties can not take effect like that at the same time, one has to leave for the other to be effective.
    So is there a better way I can achieve my aim of having the gbox be affected by the stylesheet and font?

    I love this forum. I need help please.

    C 1 Reply Last reply
    0
    • C CEO.

      Hello,

      I would appreciate someone tells me how I can set the font size of the widgets in my qgroupbox widget so all the widgets in it can be affected by the size. I saw this quote from Qt documentation

      "Note: If Qt Style Sheets are used on the same widget as setFont(), style sheets will take precedence if the settings conflict"
      

      I already set stylesheet to the qgroupbox, therefore applying the .setFont() method does not work. It will only work if I deactivate the .setStyleSheet property from the qgroupwidget owing to the standard rule.

      So how can I apply stylesheet and font to the same qwidget such as qgroupbox?

       gbox = QGroupBox()
       gbox.setStylesheet("background-color: blue; color: yellow")
       gbox.setFont(20)
      

      Now, the gbox widget has two properties there, .setStyleSheet and .setFont, the two properties can not take effect like that at the same time, one has to leave for the other to be effective.
      So is there a better way I can achieve my aim of having the gbox be affected by the stylesheet and font?

      I love this forum. I need help please.

      C Offline
      C Offline
      CEO.
      wrote on last edited by
      #2

      I finally resolved it using this:

        gbox2.setStyleSheet("background-color: beige; color: olivedrab; font: bold 18px")
      
      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