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

Using of property mouse.accepted



  • Hello,

    I'm working on upgrade of my application to Qt6. I have a code, which looks like this:

                MouseArea {
                    id: myMouseArea
                    anchors.fill: parent
                    enabled: true
                    propagateComposedEvents: true
    
                    onPressed: {
                        mouse.accepted = false;
                        doSomething();
                    }
                }
    

    Below this MouseArea is another one. What I need to achieve is that clicking this MouseArea will be propagated also to the item below. This code works fine, but in Qt6 I get this warning:

    qt.qml.context: qrc:/qml/MainTouch.qml:393:13 Parameter "mouse" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
    

    How do I fix this problem?

    Generally, I have a lot of issues with removed or renamed properties between Qt5 and Qt6. But I'm having a really hard time to find out what and why has been something changed. Is there any documentation, that could help me with that? Thank you.



  • @vlada said in Using of property mouse.accepted:

    How do I fix this problem?

    I would say replace mouse by myMouseArea
    According to documentation, you have to change like this:

    onPressed: (mouse)=> {
                    mouse.accepted = false
                    doSomething();
                }
    

    cf: https://doc.qt.io/qt-6/qml-qtquick-mousearea.html or https://doc.qt.io/qt-6/qtquick-mousearea-example.html



  • Thank you! This works fine.


  • Qt Champions 2018

    not that for a single parameter you can get rid of the parenthesis, mouse => { ... } works


Log in to reply