Reputation: 315
I have a question regarding the QGroupBox stylesheet. I want a custom stylesheet for QGroupBox that looks similar to the image below:
Can you please tell me how to look "Device Info" Style with white background?
Upvotes: 1
Views: 17916
Reputation: 12731
Use setStyleSheet
function to set any style for any state programmatically.
For your case, first obtain the QGroupBox
object and let us assume "pGroupBox".
As you need title's back ground color to be white, you can set it as shown below.
pGroupBox->setStyleSheet("::title{background-color:white}");
Almost you can style anything check below link: (you can set based on different psuedo states for different sub controls.)
http://doc.qt.io/qt-5.8/stylesheet-examples.html
Upvotes: 2
Reputation: 30638
You can change the color here
QGroupBox {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #E0E0E0, stop: 1 #FFFFFF);
border: 2px solid gray;
border-radius: 5px;
margin-top: 1ex; /* leave space at the top for the title */
}
specify the color whatever you want at the place of red.
Look at the Qt Style Sheets Examples.
Upvotes: 0
Reputation: 13130
You need to change style for QGroupBox::title subcontrol. http://developer.qt.nokia.com/doc/qt-4.7/stylesheet-examples.html#id-e7d01e98-168f-4c8a-ac7f-77233a406ba4
Upvotes: 0