Forwarding mouse events



  • I need to create 2 MouseArea's - one above the other, and i want that
    both of them will get the signal pressed.

    something like this:

    @
    MouseArea
    {
    id: mouseArea1
    anchors.fill: parent

        onPressed:
        {
            console.log("onPressed 1")
            mouse.accepted = false;
        }
    }
    
    MouseArea
    {
        id: mouseArea2
        anchors.fill: parent
    
    
        onPressed:
        {
            console.log("onPressed 2")
           // this is not accepted(only clicked, and this is not what i need)
            mouseArea1["pressed"](mouse);         
        }
    

    }
    @

    any idea?



  • Since mouseArea2 is on top of mouseArea1 you've to forward the event from mouseArea2

    @

    MouseArea
    {
    id: mouseArea1
    anchors.fill: parent

        onPressed:
        {
            console.log("onPressed 1")
         }
    }
    
    MouseArea
    {
        id: mouseArea2
        anchors.fill: parent
    
    
        onPressed:
        {
            console.log("onPressed 2")
            mouse.accepted = false;
        }
    }
    

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.