Please forgive me if I don't completely understand...
Maybe you want an underlying mouse area, not an overlaynig one? I'd suggest you just move the MouseArea in the file.
You can always use an overlaying one and translate the mouse events to the child, if there is one. This is what I do for a sample drawing app I have:
In TouchTestRect.qml: function dispatchTouchEvent(x,y) { var c = childAt(x,y); var typename = "" + c;
var box;if (c && (typename.startsWith("QQuickRow") || typename.startsWith("QQuickColumn"))) { var point = mapToItem(c, x, y); box = c.childAt(point.x, point.y); typename = "" + box; } else if(typename.startsWith("TouchHitBox_QMLTYPE")) {....}...}then:MouseArea {anchors.fill: parentonMouseXChanged: {touchTestRect.dispatchTouchEvent(mouseX, mouseY)}onMouseYChanged: {touchTestRect.dispatchTouchEvent(mouseX, mouseY)}
}
Sent: Thursday, March 21, 2019 at 7:50 AM
From: "René Hansen" <ren...@gmail.com>
To: interest <interest@qt-project.org>
Subject: [Interest] Track global mouse position in QML
From: "René Hansen" <ren...@gmail.com>
To: interest <interest@qt-project.org>
Subject: [Interest] Track global mouse position in QML
Hi all,
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interestI want to track mouse movement within my entire application window, because I need to show/hide/move items around where my cursor is at certain times. (Think e.g. custom cursor)
I can do it easily by filling the entire window with a MouseArea and handle onPositionChanged. The problem is that any mouse sensitive inputs underneath, then get's blocked by the overlaying MouseArea. E.g. a TextField that is usually highlighted on hover and clickable, no longer receives any mouse events.
Is there any straightforward solution to this?
I know QQuickWindow has a mouseMoveEvent, but that doesn't seem to be exposed in QML and if I can avoid subclassing and exposing a custom class, I'd rather do that.
Cheers,
I can do it easily by filling the entire window with a MouseArea and handle onPositionChanged. The problem is that any mouse sensitive inputs underneath, then get's blocked by the overlaying MouseArea. E.g. a TextField that is usually highlighted on hover and clickable, no longer receives any mouse events.
Is there any straightforward solution to this?
I know QQuickWindow has a mouseMoveEvent, but that doesn't seem to be exposed in QML and if I can avoid subclassing and exposing a custom class, I'd rather do that.
Cheers,
René Hansen
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest