Problem: Stylesheet for QGroupBox
Solved
General and Desktop
-
I have a QGridLayout with several QGroupBoxes. This is what one of these boxes looks like at the moment:
This is what I would like to have:
Three thing need to happen:- Move the groupbox title upwards.
- Turn the groupbox title to blue.
- 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 -
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 ;-)