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. Problem: Stylesheet for QGroupBox

Problem: Stylesheet for QGroupBox

Scheduled Pinned Locked Moved Solved General and Desktop
qgroupboxstylesheet
3 Posts 2 Posters 3.9k 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.
  • W Offline
    W Offline
    willemf
    wrote on last edited by
    #1

    I have a QGridLayout with several QGroupBoxes. This is what one of these boxes looks like at the moment:
    0_1556533364650_I_have.png
    This is what I would like to have:
    0_1556533449607_I_want.jpg
    Three thing need to happen:

    1. Move the groupbox title upwards.
    2. Turn the groupbox title to blue.
    3. Reduce the horizontal padding between the contents of the text in order to take up less horizontal space.

    I have been using the setStyleSheet command, but with little success. Here is what I currently have:

    	containerWidget->setStyleSheet("QGroupBox { border: 1px solid blue;}");
    	containerWidget->setStyleSheet("QGroupBox::title {padding-top: -24px; padding-left: 8px;} ");
    
    

    Setting the second stylesheet undoes the first one. Then I tried this in one single instruction.

    containerWidget->setStyleSheet("QGroupBox { border: 1px solid blue;}"); QGroupBox::title { subcontrol-origin: margin; left: 7px; padding: 0px 5px 0px 5px;}");
    //your code here
    

    This does not work either.

    Any help will be highly appreciated.
    Kind regards, willem

    J.HilkJ 1 Reply Last reply
    0
    • J.HilkJ J.Hilk

      @willemf

      Et voilà :

      containerWidget->setStyleSheet("QGroupBox{background-color: transparent; border: 1px solid blue; border-radius: 5px; margin-top: 3ex;} QGroupBox:title {subcontrol-position: top middle; padding: -14px 0px 0px 3px; color:blue;}");
      

      It's not exactly what you wan't but it's a working snipped from one of my projects ;-)

      W Offline
      W Offline
      willemf
      wrote on last edited by
      #3

      @J.Hilk
      Merci beaucoup, JH, c'est parfait!
      wf

      1 Reply Last reply
      0
      • W willemf

        I have a QGridLayout with several QGroupBoxes. This is what one of these boxes looks like at the moment:
        0_1556533364650_I_have.png
        This is what I would like to have:
        0_1556533449607_I_want.jpg
        Three thing need to happen:

        1. Move the groupbox title upwards.
        2. Turn the groupbox title to blue.
        3. Reduce the horizontal padding between the contents of the text in order to take up less horizontal space.

        I have been using the setStyleSheet command, but with little success. Here is what I currently have:

        	containerWidget->setStyleSheet("QGroupBox { border: 1px solid blue;}");
        	containerWidget->setStyleSheet("QGroupBox::title {padding-top: -24px; padding-left: 8px;} ");
        
        

        Setting the second stylesheet undoes the first one. Then I tried this in one single instruction.

        containerWidget->setStyleSheet("QGroupBox { border: 1px solid blue;}"); QGroupBox::title { subcontrol-origin: margin; left: 7px; padding: 0px 5px 0px 5px;}");
        //your code here
        

        This does not work either.

        Any help will be highly appreciated.
        Kind regards, willem

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #2

        @willemf

        Et voilà :

        containerWidget->setStyleSheet("QGroupBox{background-color: transparent; border: 1px solid blue; border-radius: 5px; margin-top: 3ex;} QGroupBox:title {subcontrol-position: top middle; padding: -14px 0px 0px 3px; color:blue;}");
        

        It's not exactly what you wan't but it's a working snipped from one of my projects ;-)


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        W 1 Reply Last reply
        2
        • J.HilkJ J.Hilk

          @willemf

          Et voilà :

          containerWidget->setStyleSheet("QGroupBox{background-color: transparent; border: 1px solid blue; border-radius: 5px; margin-top: 3ex;} QGroupBox:title {subcontrol-position: top middle; padding: -14px 0px 0px 3px; color:blue;}");
          

          It's not exactly what you wan't but it's a working snipped from one of my projects ;-)

          W Offline
          W Offline
          willemf
          wrote on last edited by
          #3

          @J.Hilk
          Merci beaucoup, JH, c'est parfait!
          wf

          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