Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Stylesheet of QGroupBox does not work properly



  • Hello,
    I have some widgets (a 2x2 table and 2 labels) inside a QGroupBox. Everything works as expected. See Picture:
    bild_ohne_stylesheet.png
    But then I want to change the color of the border. I use

    groupbox.setStyleSheet("QGroupBox {border: 1px solid black;}")
    

    Which has the wanted effect of changing the color, but it also seems to mess up some margins or paddings. See picture:
    bild_mit_stylesheet.png

    So how do i change the border color/size/radius without touching the other parameters?
    And how do i change the title size without touching anything else?
    Or what are the parameters i need to change with that, to make it look like the first picture?

    Thanks in advance



  • @Moesen said in Stylesheet of QGroupBox does not work properly:

    But then I want to change the color of the border.

    Then why not use border-color: black so as not to alter anything else like the border size?

    Also, you may get different effects (desirable or not) via groupbox.setStyleSheet("border-color: black;") without the QGroupBox?


Log in to reply