Skip to content

Commit 5f97236

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 5f97236

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/solum_qt/main.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ 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 does not have this issue, and looks much nicer in
23+
// general. We only override the specific `windowsvista` style though:
24+
// Other styles don't have this issue, and we do want to retain a
25+
// potential system-wide Qt style setting, especially on Linux.
26+
//
27+
// QStyle::name() is also only available on Qt 6.1 and above.
28+
#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)
29+
if (a.style()->name() == "windowsvista") {
30+
QApplication::setStyle("fusion");
31+
}
32+
#endif
33+
1634
QCoreApplication::setOrganizationName(QStringLiteral("Clarius"));
1735
QCoreApplication::setOrganizationDomain(QStringLiteral("clarius.com"));
1836
QCoreApplication::setApplicationName(QStringLiteral("Solum Demo"));

0 commit comments

Comments
 (0)