Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QQuickItem::mousePressEvent() not called



  • Hi all,

    I'm experiencing an issue with QQuickItem objects.
    Basically, I have an app with custom QMdiSubWindow.

    MyMdiSubWindow contains a QQuickWidget as its central widget.

    The QQuickWidget holds a MyObjectScene that inherits from
    QQuickItem. The purpose of this class is to store child items, selected child objects etc.

    MyObjectScene manages ElementItem objects.
    ElementItem inherits from QQuickPaintedItem.
    ElementItem overrides mousePressEvent() and mouseReleaseEvent().
    It works fine.

    However, sometime, when ElementItem rejects a mousePressEvent with
    event->ignore(), I would like MyObjectScene to intercept the event afterward in its
    mousePressEvent() handler.
    But it never happens.

    However, if I override MySubWindow::mousePressEvent() , I can catch the event.
    It means that, MySubWindow::mousePressEvent() is called when ElementItem::mousePressEvent ignores the event.

    What I need to do, is to have MyObjectScene::mousePressEvent() called instead of MySubWindow::mousePressEvent.

    Is there something wrong in this scenario ?

    Thanks for your feedback.

    Karim


Log in to reply