Non Rectangular Mouse Area. (Triangular or polygon) [Solved]
-
wrote on 17 Sept 2013, 07:18 last edited by
Is there a way to catch mouse event in a triangular or polygon area? At least a workaround. I'm using Qt Quick 2
-
wrote on 17 Sept 2013, 08:48 last edited by
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.
-
wrote on 17 Sept 2013, 10:53 last edited by
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.
-
wrote on 17 Sept 2013, 11:01 last edited by
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);
@ -
wrote on 17 Sept 2013, 11:08 last edited by
Wonderful, it works!
Thank you, very much. -
wrote on 28 Jan 2016, 21:30 last edited by Larpon
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) -
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) -
wrote on 4 Feb 2016, 12:21 last edited by
@TOMATO_QT
Thanks!