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

Drawer bug?



  • I've got a Quick Controls 2 app that has a structure that looks like this:

    Flippable
         Front
             StackView
                  Page 1
                     ListView w/ScrollBar
                  Page 2
         Back
             Tab View
                 Tab 1
                 Tab 2
                     Drawer
    
    

    I've been chasing a bug in which the ListView's scroll bar was unresponsive to mouse input. After much experimentation, I discovered that the Drawer's dragMargin, which was set to Qt.styleHints.startDragDistance was the culprit. It created a dead zone on the right side of every view (not just Tab 2), which was unresponsive to clicks.

    Is this the expected behavior of a Drawer? I would have thought that the dragMargin would only apply to the Tab2 view, not to every view in the app.
    Are Drawers intended to be global?



  • Here's a simple example of the bug:

    main.qml

    import QtQuick 2.10
    import QtQuick.Window 2.10
    import QtQuick.Controls 2.3
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Flipable {
            id: flipable
            anchors.fill:parent
    
            property bool flipped: false
    
            front: Front{}
            back: Back{}
    
            states: State {
                name: "back"
                PropertyChanges { target: rotation; angle: 180 }
                when: flipable.flipped
            }
    
            transform: Rotation {
                id: rotation
                origin{ x: flipable.width/2;y: flipable.height/2 }
                axis{ x: 0;y: -1;z: 0 }    // set axis.y to 1 to rotate around y-axis
                angle: 0    // the default angle
            }
    
            transitions: Transition {
                NumberAnimation { target: rotation; property: "angle"; duration: 2000 }
            }
    
    
        }
    
        RoundButton{
            height:40
            width:40
            radius:20
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            text:"flip"
    
            onClicked: flipable.flipped = !flipable.flipped
        }
    }
    
    

    Front.qml:

    import QtQuick 2.10
    import QtQuick.Controls 2.3
    
    Item {
        id:frontSide
        anchors.fill:parent
    
        ListView {
            anchors.fill:parent
    
            model: 100
    
            delegate: ItemDelegate {
                Text { text: "Item number: " + index }
                width: parent.width
            }
    
            ScrollBar.vertical: ScrollBar {
                policy:ScrollBar.AlwaysOn
                width:10
            }
        }
    
    }
    

    Back.qml:

    import QtQuick 2.10
    import QtQuick.Controls 2.3
    
    Item {
        id:backSide
        anchors.fill:parent
    
        Drawer{
            id:theDrawer
            x: parent.width
            y: 0
            height: parent.height
            width: parent.width/2
            edge: Qt.RightEdge
            dragMargin: Qt.styleHints.startDragDistance
    
            Text{
                anchors.centerIn: parent
                text:"I'm a drawer!"
            }
    
        }
    }
    

    The code demonstrates that the scroll bar on the front side doesn't respond to clicks because of the dragMargin of the drawer on the back



  • It's a known problem: QTBUG-59141. In your scenario, you can mitigate the problem by setting Drawer::interactive to false when applicable.


Log in to reply