Handling colorSchemeChanged
Unsolved
General and Desktop
-
I have a class that initialises a colour name in the ctor initialiser list:
windowColourName{ palette().color(QPalette::ColorRole::Window).name()}, // Default base window colour
If the active windows theme is a Light theme it is set to "#f0f0f0" at that point.
If the active windows theme is a Dark theme it is set to "#1e1e1e"
If I switch themes, I enter this code:
void ExplorerBar::onColorSchemeChanged(Qt::ColorScheme scheme) { // // Dark colour scheme? // if (Qt::ColorScheme::Dark == scheme) activeGroupColourName = "darkcyan"; else activeGroupColourName = "lightcyan"; windowColourName = palette().color(QPalette::ColorRole::Window).name(); // Default base window colour const auto tabID = dssApp->tab(); if (IDD_REGISTERING == tabID) { ui->registerAndStack->setStyleSheet(QString("background-color: %1").arg(activeGroupColourName)); ui->processing->setStyleSheet(QString("background-color: %1").arg(windowColourName)); } else { ui->registerAndStack->setStyleSheet(QString("background-color: %1").arg(windowColourName)); ui->processing->setStyleSheet(QString("background-color: %1").arg(activeGroupColourName)); } ui->options->setStyleSheet(QString("background-color: %1").arg(activeGroupColourName)); makeLinks(); }
My problem is that the line that sets windowColourName is returning #1e1e1e when switching to a light theme from a Dark theme, or #f0f0f0 when switching the other way.
What do I need to call to ensure I pick up the updated window colour?
Thanks
David