Skip to content

Commit 00dffa3

Browse files
Qt: use the fusion style on Windows to work around wrong button label colors
Kind of unfortunate, but the `fusion` style looks nicer anyway.
1 parent 7c8acaa commit 00dffa3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/solum_qt/main.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ int main(int argc, char *argv[])
1313
{
1414
QApplication a(argc, argv);
1515

16+
// When using the default `windowsvista` style on Windows 10 in Dark Mode,
17+
// Qt 6.5.1 renders the labels of disabled QPushButtons with the same
18+
// black color as enabled ones, making it hard to distinguish the two:
19+
//
20+
// https://bugreports.qt.io/browse/QTBUG-115036
21+
//
22+
// The `fusion` style is bundled with Qt as well, does not have this issue,
23+
// and looks much nicer in general. We only override the specific
24+
// `windowsvista` style though: Other styles don't have this issue, and we
25+
// do want to retain a potential system-wide Qt style setting, especially
26+
// on Linux.
27+
//
28+
// QStyle::name() is also only available on Qt 6.1 and above.
29+
#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
30+
if (a.style()->name() == "windowsvista") {
31+
QApplication::setStyle("fusion");
32+
}
33+
#endif
34+
1635
QCoreApplication::setOrganizationName(QStringLiteral("Clarius"));
1736
QCoreApplication::setOrganizationDomain(QStringLiteral("clarius.com"));
1837
QCoreApplication::setApplicationName(QStringLiteral("Solum Demo"));

0 commit comments

Comments
 (0)