From 6aea9a3ce916b71f0286165230151fc1d3622d0c Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Sat, 25 Jul 2020 10:19:15 +0800 Subject: [PATCH] Adapt to Qt6 change. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- winnativeeventfilter.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index 198e7b2..2e619bb 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) #include #else @@ -42,6 +41,12 @@ #include #endif #include +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) +#include +#else +#include +#include +#endif #ifdef WNEF_LINK_SYSLIB #include #include @@ -54,7 +59,7 @@ Q_DECLARE_METATYPE(QMargins) namespace { #if (QT_VERSION < QT_VERSION_CHECK(5, 7, 0)) -#define qAsConst std::as_const +#define qAsConst(i) std::as_const(i) #endif #ifndef USER_DEFAULT_SCREEN_DPI @@ -1868,6 +1873,7 @@ void WinNativeEventFilter::updateQtFrame(QWindow *window, const int titleBarHeig // window. window->setProperty("_q_windowsCustomMargins", marginsVar); // If a platform window exists, change via native interface. +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) QPlatformWindow *platformWindow = window->handle(); if (platformWindow) { QGuiApplication::platformNativeInterface() @@ -1875,6 +1881,13 @@ void WinNativeEventFilter::updateQtFrame(QWindow *window, const int titleBarHeig QString::fromUtf8("WindowsCustomMargins"), marginsVar); } +#else + auto *platformWindow = dynamic_cast( + window->handle()); + if (platformWindow) { + platformWindow->setCustomMargins(margins); + } +#endif } }