Active/Inactive background colour switching
Unsolved
General and Desktop
-
I have setup a Palette for a groupbox as follows:
QPalette palette; QBrush brush(QColor(217, 224, 240, 255)); brush.setStyle(Qt::SolidPattern); palette.setBrush(QPalette::Active, QPalette::Window, brush); QBrush brush1(QColor(240, 240, 240, 255)); brush1.setStyle(Qt::SolidPattern); palette.setBrush(QPalette::Inactive, QPalette::Window, brush1); palette.setBrush(QPalette::Disabled, QPalette::Window, brush1); groupbox.setPalette(palette);
How do I get the groupbox to switch between the Active and Inactive colours? Clicking on it doesn't seem to do much.
-
Hi,
From memory, inactive is for when the container widget is inactive. Usually when another window or application has the focus.
-
In the end I gave up on that approach and did this:
oid ExplorerBar::mousePressEvent(QMouseEvent *event) { if (Qt::LeftButton == event->buttons()) { const auto dwTabID = dssApp->tab(); if ((ui->registerAndStack->underMouse()) && (dwTabID != IDD_REGISTERING) && (dwTabID != IDD_STACKING)) { ui->registerAndStack->setStyleSheet("background-color: lightcyan"); ui->processing->setStyleSheet("background-color: rgb(240, 240, 240)"); // Change tab to stacking dssApp->setTab(IDD_STACKING); } else if (ui->processing->underMouse() && (dwTabID != IDD_PROCESSING)) { ui->registerAndStack->setStyleSheet("background-color: rgb(240, 240, 240)"); ui->processing->setStyleSheet("background-color: lightcyan"); // Change tab to processing dssApp->setTab(IDD_PROCESSING); }; } Inherited::mousePressEvent(event); }