From 203274a522c73e3444a0ea641e8fa0c28ecbb306 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Fri, 16 Oct 2020 01:00:11 +0800 Subject: [PATCH] feat: try using QWindow::startSystemMove() under Qt 5.15+ --- mainwindow.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mainwindow.cpp b/mainwindow.cpp index 8479c1c..28be67a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #ifdef _WIN32 #include @@ -339,7 +340,13 @@ void MainWindow::mousePressEvent(QMouseEvent *event) void MainWindow::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() & Qt::LeftButton && m_clickedOnWindow && !isMaximized()) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + if (!window()->windowHandle()->startSystemMove()) { + move(event->globalPos() - m_oldMousePos); + } +#else move(event->globalPos() - m_oldMousePos); +#endif // QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) event->accept(); }