From 01dd43c3567cfb7e8086fa74f9237aed9774f4d3 Mon Sep 17 00:00:00 2001 From: Altair Wei Date: Mon, 23 Aug 2021 09:29:50 +0800 Subject: [PATCH] fix unwanted cursor change when leave edge region (#80) --- examples/mainwindow/MainWindow.ui | 9 ++++++++- framelesshelper.cpp | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/mainwindow/MainWindow.ui b/examples/mainwindow/MainWindow.ui index f20bcc4..638a9fe 100644 --- a/examples/mainwindow/MainWindow.ui +++ b/examples/mainwindow/MainWindow.ui @@ -7,7 +7,7 @@ 0 0 518 - 362 + 368 @@ -152,6 +152,13 @@ + + + + <a href="https://www.google.com">https://www.google.com</a> + + + diff --git a/framelesshelper.cpp b/framelesshelper.cpp index af92047..4eb3a36 100644 --- a/framelesshelper.cpp +++ b/framelesshelper.cpp @@ -158,19 +158,27 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event) } } else if (type == QEvent::MouseMove) { // Display resize indicators + static bool cursorChanged = false; if ((window->windowState() == Qt::WindowState::WindowNoState) && resizable) { if (((edges & Qt::TopEdge) && (edges & Qt::LeftEdge)) || ((edges & Qt::BottomEdge) && (edges & Qt::RightEdge))) { window->setCursor(Qt::SizeFDiagCursor); + cursorChanged = true; } else if (((edges & Qt::TopEdge) && (edges & Qt::RightEdge)) || ((edges & Qt::BottomEdge) && (edges & Qt::LeftEdge))) { window->setCursor(Qt::SizeBDiagCursor); + cursorChanged = true; } else if ((edges & Qt::TopEdge) || (edges & Qt::BottomEdge)) { window->setCursor(Qt::SizeVerCursor); + cursorChanged = true; } else if ((edges & Qt::LeftEdge) || (edges & Qt::RightEdge)) { window->setCursor(Qt::SizeHorCursor); + cursorChanged = true; } else { - window->setCursor(Qt::ArrowCursor); + if (cursorChanged) { + window->setCursor(Qt::ArrowCursor); + cursorChanged = false; + } } }