Flickable below an item still scrolling



  • I have a Qt use case, where I draw a semi-transparent overlay over a Flickable (for example GridView). If I scroll the mouse over the overlay, I would like flickable below not to scroll. Is there a simple way to achieve that (not do disable and enable flickable each time I hide/show overlay)?

    Example code:
    @import QtQuick 2.1

    Rectangle {
    width: 360
    height: 360

    Flickable {
        anchors.fill: parent
        contentWidth: 360
        contentHeight: 500
    
        Rectangle {
            width: 360
            height: 500
    
            Rectangle {
                anchors.centerIn: parent
                color:"red"
                width: 360
                height: 10
            }
        }
    }
    
    Rectangle {
        anchors.fill: parent
        color: "#99000000"
    }
    

    }

    @


  • Moderators

    Hi,

    If I understood you correctly you could set "interactive":http://doc.qt.io/qt-5/qml-qtquick-flickable.html#interactive-prop when you dont want to scroll.



  • I know that, I was wondering if there is a more general way to catch all mouse events using one Item and don't pass them through to items below.


  • Moderators

    Well since that semi transparent rect is your overlay you can define a MouseArea for it and then accept all the wheel events thus stopping it from propagating.
    @
    Rectangle {
    anchors.fill: parent
    color: "#99000000"

    MouseArea {
        anchors.fill: parent
        onWheel: wheel.accepted = true
    }
    

    }
    @


Log in to reply
 

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