[Interest] MouseArea blocks 'Custom Scene Graph Item's mouse events
Sina Dogru
sinadooru at gmail.com
Mon Feb 22 13:43:19 CET 2016
Thank you Curtis but as you can see it on my code snippet on the question,
I have already tried to set 'propagateComposedEvents' to true. But it did
not worked :S
2016-02-22 14:40 GMT+02:00 Curtis Mitch <mitch.curtis at theqtcompany.com>:
>
>
>
>
> *From:* Interest [mailto:interest-bounces+mitch.curtis=
> theqtcompany.com at qt-project.org] *On Behalf Of *Sina Dogru
> *Sent:* Monday, 22 February 2016 1:15 PM
> *To:* interest at qt-project.org
> *Subject:* [Interest] MouseArea blocks 'Custom Scene Graph Item's mouse
> events
>
>
>
> Hello,
>
> I am implementing a custom scene graph item, which inherits QQuickItem
> <http://doc.qt.io/qt-5/qquickitem.html>.
>
> class CustomItem : public QQuickItem {
>
> Q_OBJECT
>
> public:
>
> CustomItem()
>
> {
>
> setAcceptHoverEvents(true);
>
> setAcceptedMouseButtons(Qt::LeftButton);
>
> setFlag(ItemHasContents);
>
> }
>
> protected:
>
> QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
>
>
>
> void hoverEnterEvent(QHoverEvent *e) override;
>
> void hoverLeaveEvent(QHoverEvent *e) override;
>
> void hoverMoveEvent(QHoverEvent *e) override;
>
>
>
> void mouseMoveEvent(QMouseEvent *e) override;
>
> void mouseReleaseEvent(QMouseEvent *e) override;
>
> void mousePressEvent(QMouseEvent *e) override;
>
> };
>
>
>
> And I use that CustomItem as a visual parent to some QML Types, like
> Rectangle <http://doc.qt.io/qt-5/qml-qtquick-rectangle.html>.
>
> CustomItem {
>
> id: custom
>
> width: 400; height: 400
>
> Rectangle {
>
> id: rect
>
> z: -1
>
> anchors.fill: parent
>
> color: "blue"
>
> }
>
> }
>
> Everything was perfect, I was able to draw over the visual childrens using
> 'z' property with overriding QQuickItem::updatePaintNode.
>
> But the problem raised when I use MouseArea
> <http://doc.qt.io/qt-5/qml-qtquick-mousearea.html> as a children of my
> 'CustomItem'.
>
> CustomItem {
>
> id: custom
>
> width: 400; height: 400
>
> Rectangle {
>
> id: rect
>
> z: -1
>
> anchors.fill: parent
>
> color: "blue"
>
> }
>
> MouseArea {
>
> anchors.fill: parent
>
> propagateComposedEvents: true
>
> drag.target: parent
>
> drag.axis: Drag.XandYAxis
>
> }
>
> }
>
> After that, my 'CustomItem' was not getting the mouse events like
> QQuickItem::hoverEnterEvent
> <http://doc.qt.io/qt-5/qquickitem.html#hoverEnterEvent> ,
> QQuickItem::mousePressEvent
> <https://forum.qt.io/topic/64437/doc.qt.io/qt-5/qquickitem.html#mousePressEvent>
> or QQuickItem::mouseMoveEvent
> <http://doc.qt.io/qt-5/qquickitem.html#mouseMoveEvent> which those are
> crucial to implement in my case.
>
> I am not sure if this even possible or am I doing something wrong? If
> there is a candidate solution for that particular problem, I would be happy
> to try it.
>
> Note: Here is a similar question on StackOverFlow
> <http://stackoverflow.com/questions/23986201/mouse-events-not-handled-within-qquickitem-inheritor>
> which have not been replied.
>
>
>
> There is an answer for that question. What happens if you try it? You can
> also try setting propagateComposedEvents to true:
>
>
> http://doc.qt.io/qt-5/qml-qtquick-mousearea.html#propagateComposedEvents-prop
>
> I have already asked it question on QtForums
> <https://forum.qt.io/topic/64437/mousearea-blocks-custom-scene-graph-item-s-mouse-events>
> .
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160222/d9dcba11/attachment.html>
More information about the Interest
mailing list