Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling the title of a QGroupBox

Tags:

qt

Given a QGroupBox, calling its member function, "setEnabled(false)" will grey out and disable its contents.

However, how do I grey out the title of the box? Presumably there's some workaround involving styles that I could use if there isn't a simple method somewhere. If so, what is the easiest?

like image 543
JimmidyJoo Avatar asked Mar 06 '12 11:03

JimmidyJoo


1 Answers

What you need to set is the color property of the title sub-control:

groupBox->setStyleSheet("QGroupBox::title{ color: gray }")

EDIT

You could also achieve the same effect using QPalette, without the use of stylesheets

// Create a palette
QPalette palette;
palette.setColor(QPalette::Disabled, QPalette::WindowText,
                 QApplication::palette().color(QPalette::Disabled, QPalette::WindowText));
groupBox->setPalette(palette);
like image 50
pnezis Avatar answered Oct 11 '22 14:10

pnezis