Non Rectangular Mouse Area. (Triangular or polygon) [Solved]
-
Is there a way to catch mouse event in a triangular or polygon area? At least a workaround. I'm using Qt Quick 2
-
You can write a custom QQuickItem in C++. There is an example called maskedmousearea included in Qt 5.1 which should demonstrate how to do this.
It is also possible to do this in pure QML by handling onPressed and onReleased manually and simply verifying if the mouse area is within your region.
-
Thank you! by the time you reply this I figured it out, and now I'm writing a custom QQuickItem.
I have another issue related to this, seems mousePressEvent(or any other mouse events) not triggered.
-
You should just look at maskedmousearea as it does exactly what you want. Perhaps you forgot to do the following:
@
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::LeftButton);
@ -
Wonderful, it works!
Thank you, very much. -
Necro asking :)
Is this still the way to go in 2016?
It's seems like the example has vanished in Qt5.5 (probably earlier versions) -
I found the maskmousearea example in the Qt 5.5 install at
/Examples/Qt-5.5/quick/customItems/
-
@TOMATO_QT
Thanks!