Change mouse cursor shape for a desktop application when hovering over a QML element
-
Hi
I have a desktop application with UI written in QML. I am using mouse area to detect when the mouse hovers over a given region. When the mouse enters the region I am using:
QCursor *cursor = QGuiApplication::overrideCursor();
if (NULL != cursor) {
QGuiApplication::restoreOverrideCursor();//empty stack first
}
QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);then when the mouse leaves the region:
QCursor *cursor = QGuiApplication::overrideCursor(); if (NULL != cursor) { QGuiApplication::restoreOverrideCursor(); }
My approach seems to work, but I get situations, at application startup for example, when the mouse cursor does not change shape. When I hide the main window, then show it again the mouse cursor changes shape. For the main window I am using QQuickView as the base class and I am loading my QML files. For widgets I have seen that there is setMouseTracking method, but this one is not available for QQuickView. Could someone tell me what is the reliable way to change mouse cursor shape when hovering over a QML element ?
thanks
Bogdan