diff --git a/examples/Quick/Quick.pro b/examples/Quick/Quick.pro index d8ed467..529fecb 100644 --- a/examples/Quick/Quick.pro +++ b/examples/Quick/Quick.pro @@ -1,6 +1,6 @@ TARGET = Quick TEMPLATE = app -QT += quick +QT += quick quickcontrols2 HEADERS += ../../framelessquickhelper.h SOURCES += ../../framelessquickhelper.cpp main.cpp RESOURCES += qml.qrc diff --git a/examples/Quick/main.cpp b/examples/Quick/main.cpp index 1f70f77..cfc652a 100644 --- a/examples/Quick/main.cpp +++ b/examples/Quick/main.cpp @@ -25,6 +25,7 @@ #include "../../framelessquickhelper.h" #include #include +#include int main(int argc, char *argv[]) { @@ -52,6 +53,12 @@ int main(int argc, char *argv[]) QGuiApplication application(argc, argv); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + QQuickStyle::setStyle(QString::fromUtf8("Basic")); +#else + QQuickStyle::setStyle(QString::fromUtf8("Default")); +#endif + QQmlApplicationEngine engine; qmlRegisterType("wangwenx190.Utils", 1, 0, "FramelessHelper"); const QUrl mainQmlUrl(QString::fromUtf8("qrc:///qml/main.qml")); diff --git a/examples/Quick/qml/main_windows.qml b/examples/Quick/qml/main_windows.qml index d22d424..23a7954 100644 --- a/examples/Quick/qml/main_windows.qml +++ b/examples/Quick/qml/main_windows.qml @@ -172,6 +172,6 @@ Window { Component.onCompleted: { framelessHelper.setWindowFrameVisible(framelessHelper.canHaveWindowFrame) - framelessHelper.removeWindowFrame(true) + framelessHelper.removeWindowFrame() } } diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index 950a15d..0957333 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -780,10 +780,7 @@ void triggerFrameChange(const QWindow *window) void updateFrameMargins(const QWindow *window, bool reset) { Q_ASSERT(window); - MARGINS margins = {0, 0, 0, 0}; - if (!reset) { - margins.cyTopHeight = 1; - } + const MARGINS margins = reset ? MARGINS{0, 0, 0, 0} : MARGINS{1, 1, 1, 1}; WNEF_EXECUTE_WINAPI(DwmExtendFrameIntoClientArea, reinterpret_cast(window->winId()), &margins) @@ -824,13 +821,15 @@ void installHelper(QWindow *window, const bool enable) window, WinNativeEventFilter::SystemMetric::TitleBarHeight, true, true) : 0; const QMargins margins = {0, -tbh, 0, 0}; + const QVariant marginsVar = QVariant::fromValue(margins); + window->setProperty("_q_windowsCustomMargins", marginsVar); #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QPlatformWindow *platformWindow = window->handle(); if (platformWindow) { QGuiApplication::platformNativeInterface()->setWindowProperty(platformWindow, QString::fromUtf8( "WindowsCustomMargins"), - QVariant::fromValue(margins)); + marginsVar); } #else auto *platformWindow = dynamic_cast(