From 46285db399f75154ad6c451e12f2cae2e59ace25 Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周日, 24 12月 2023 23:52:03 +0800 Subject: [PATCH] Use brilliant workaround to show Windows 10 top border --- examples/mainwindow/mainwindow.cpp | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp index 86420ac..a1a39dd 100644 --- a/examples/mainwindow/mainwindow.cpp +++ b/examples/mainwindow/mainwindow.cpp @@ -115,6 +115,10 @@ windowAgent = new QWK::WidgetWindowAgent(this); windowAgent->setup(this); +#ifdef Q_OS_WIN + windowAgent->setWindowAttribute(QStringLiteral("dark-mode"), true); +#endif + // 2. Construct your title bar auto menuBar = [this]() { auto menuBar = new QMenuBar(); @@ -153,8 +157,7 @@ auto acrylicAction = new QAction(tr("Enable acrylic material"), menuBar); acrylicAction->setCheckable(true); connect(acrylicAction, &QAction::triggered, this, [this](bool checked) { - if (!windowAgent->setWindowAttribute(QStringLiteral("acrylic-material"), - QColor::fromRgbF(1.f, 1.f, 1.f, 0.6f))) { + if (!windowAgent->setWindowAttribute(QStringLiteral("acrylic-material"), true)) { return; } setProperty("custom-style", checked); @@ -299,10 +302,6 @@ if (!styleSheet().isEmpty() && theme == currentTheme) return; currentTheme = theme; - -#ifdef Q_OS_WIN - windowAgent->setWindowAttribute(QStringLiteral("dark-mode"), currentTheme == Dark); -#endif if (QFile qss(theme == Dark ? QStringLiteral(":/dark-style.qss") : QStringLiteral(":/light-style.qss")); -- Gitblit v1.9.1