Adapt to Qt6 changes, again.

Forgot to change this file.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-07-26 09:33:41 +08:00
parent 6aea9a3ce9
commit 1cd1b0cc2b
1 changed files with 13 additions and 0 deletions

View File

@ -38,7 +38,12 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QTouchEvent> #include <QTouchEvent>
#include <QWindow> #include <QWindow>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformnativeinterface.h>
#else
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformwindow_p.h>
#endif
Q_DECLARE_METATYPE(QMargins) Q_DECLARE_METATYPE(QMargins)
@ -84,6 +89,7 @@ void FramelessHelper::updateQtFrame(QWindow *window, const int titleBarHeight)
// window. // window.
window->setProperty("_q_windowsCustomMargins", marginsVar); window->setProperty("_q_windowsCustomMargins", marginsVar);
// If a platform window exists, change via native interface. // If a platform window exists, change via native interface.
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QPlatformWindow *platformWindow = window->handle(); QPlatformWindow *platformWindow = window->handle();
if (platformWindow) { if (platformWindow) {
QGuiApplication::platformNativeInterface() QGuiApplication::platformNativeInterface()
@ -91,6 +97,13 @@ void FramelessHelper::updateQtFrame(QWindow *window, const int titleBarHeight)
QString::fromUtf8("WindowsCustomMargins"), QString::fromUtf8("WindowsCustomMargins"),
marginsVar); marginsVar);
} }
#else
auto *platformWindow = dynamic_cast<QPlatformInterface::Private::QWindowsWindow *>(
window->handle());
if (platformWindow) {
platformWindow->setCustomMargins(margins);
}
#endif
} }
} }