App: Set "windowsvista" style on Windows

This will set the pre Qt 6.7 default style.

Task-number: QTBUG-126515
Task-number: QTBUG-126548
Task-number: QTBUG-126549
Change-Id: I947bcbe859c91906f2a273a04f3142d8d42b7af1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Cristian Adam
2024-06-20 13:05:05 +02:00
parent 1f0d028b09
commit 3babe8c73c

View File

@@ -680,11 +680,18 @@ int main(int argc, char **argv)
setPixmapCacheLimit();
loadFonts();
// On 100% or 200% scaling we can use the default 'Vista' style on Windows
qreal tmp;
const bool fractionalDpi = !qFuzzyIsNull(std::modf(qApp->devicePixelRatio(), &tmp));
if (Utils::HostOsInfo::isWindowsHost() && fractionalDpi && !hasStyleOption)
QApplication::setStyle(QLatin1String("fusion"));
if (Utils::HostOsInfo::isWindowsHost() && !hasStyleOption) {
// The Windows 11 default style (Qt 6.7) has major issues, therefore
// set the previous default style: "windowsvista"
// FIXME: check newer Qt Versions
QApplication::setStyle(QLatin1String("windowsvista"));
// On scaling different than 100% or 200% use the "fusion" style
qreal tmp;
const bool fractionalDpi = !qFuzzyIsNull(std::modf(qApp->devicePixelRatio(), &tmp));
if (fractionalDpi)
QApplication::setStyle(QLatin1String("fusion"));
}
const int threadCount = QThreadPool::globalInstance()->maxThreadCount();
QThreadPool::globalInstance()->setMaxThreadCount(qMax(4, 2 * threadCount));