Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.0
-
None
-
windows11
Description
I changed the window icon when I switched between dark and light themes on Windows 11. However, it only takes effect for the first time.
QGuiApplication app(argc, argv); // set window icon // first time(it work fine) app.setWindowIcon(QIcon(QPixmap(app.styleHints()->colorScheme() == Qt::ColorScheme::Dark ? ":/resources/onnx-white.svg" : ":/resources/onnx.svg"))); // only work when first switched dark or light theme QObject::connect(app.styleHints(), &QStyleHints::colorSchemeChanged, &app, [&app](Qt::ColorScheme colorScheme) { qDebug() << "Color Scheme Changed: " << colorScheme; if (colorScheme == Qt::ColorScheme::Dark) app.setWindowIcon(QIcon(QPixmap(":/resources/onnx-white.svg"))); else if (colorScheme == Qt::ColorScheme::Light) app.setWindowIcon(QIcon(QPixmap(":/resources/onnx.svg"))); });