QWidget don't change color theme on macOS under specific circumstance
-
Qt 6.5.0
macOS 13.2.1int main(int argc, char **argv) { QApplication a(argc, argv); QScrollarea window; QWidget widget; QGridLayout layout(&widget); widget.setStyleSheet(R"--(.QLabel[wordWrap="false"]:focus { border-radius: 12px; border: 8px solid rgb(22, 185, 255); })--"); // I know widget has no QLabel children; some valid stylesheet is the point window.setWidget(&widget); window.show(); return a.exec(); }Run, change appearance in system setting, and then:

-
Qt 6.5.0
macOS 13.2.1int main(int argc, char **argv) { QApplication a(argc, argv); QScrollarea window; QWidget widget; QGridLayout layout(&widget); widget.setStyleSheet(R"--(.QLabel[wordWrap="false"]:focus { border-radius: 12px; border: 8px solid rgb(22, 185, 255); })--"); // I know widget has no QLabel children; some valid stylesheet is the point window.setWidget(&widget); window.show(); return a.exec(); }Run, change appearance in system setting, and then:

Hi,
Just an educated guess: setting a stylesheet triggers the use of a different style which replaces the one that mimics the system thus it might not be theme aware.
-
Hi,
Just an educated guess: setting a stylesheet triggers the use of a different style which replaces the one that mimics the system thus it might not be theme aware.
@SGaist
There're another 2 necessary factors beside stylesheet: QScrollArea & QGridLayout.And another observation: go through it: print widget and window palette's rgb, delay printing to 3s later, and switch appearance; you will find that widget palette's RGB hasn't changed, but window palette's has.