feat: try using QWindow::startSystemMove() under Qt 5.15+

This commit is contained in:
Gary Wang 2020-10-16 01:00:11 +08:00
parent 54c54e2adf
commit 203274a522

View File

@ -22,6 +22,7 @@
#include <QCollator> #include <QCollator>
#include <QClipboard> #include <QClipboard>
#include <QMimeData> #include <QMimeData>
#include <QWindow>
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
@ -339,7 +340,13 @@ void MainWindow::mousePressEvent(QMouseEvent *event)
void MainWindow::mouseMoveEvent(QMouseEvent *event) void MainWindow::mouseMoveEvent(QMouseEvent *event)
{ {
if (event->buttons() & Qt::LeftButton && m_clickedOnWindow && !isMaximized()) { 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); move(event->globalPos() - m_oldMousePos);
}
#else
move(event->globalPos() - m_oldMousePos);
#endif // QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
event->accept(); event->accept();
} }