QPalette palette; QColor midColor(100, 100, 100); // set the RGB value of the mid-color palette.setBrush(QPalette::Mid, midColor); // set the mid-color of the palette widget->setPalette(palette); // set the palette for the widget
QGroupBox *groupBox = new QGroupBox("Title"); QPalette palette; QColor midColor(100, 100, 100); palette.setBrush(QPalette::Mid, midColor); groupBox->setPalette(palette);This code creates a group box with a title and sets the mid-color of the palette to a dark gray, resulting in a dark gray background color for the group box. Package library: Qt GUI module.