Qt World Summit: Submit your Presentation

Drag Flickable with right mouse ?

  • Hello,

    I have a flickable that contains many items and I want to drag/flick it with right mouse drag.
    Note that the default implementation achieves this with left mouse drag.
    In fact, I want to reserve the left mouse drag to other purposes (like drag a rectangle to select the child items).
    Can you help on how this can be implemented ?

    Thanks in advance for your help.

  • Qt Champions 2017

    No direct property in Flickable. You need to handle the mouse event on your own. Try something like follows.

               MouseArea {
                    anchors.fill: parent
                    acceptedButtons: Qt.LeftButton | Qt.RightButton

  • @dheerendra said in Drag Flickable with right mouse ?:


    Thanks for your quick reply.
    I try it with DragHandler but it is never triggered. It seems like Flickable internally intercepts the event.

        visible: true
        width: 1280
        height: 720
        title: qsTr("Dataxel Model")
            id: flickableID
            anchors.centerIn: parent
            width: 700
            height: 500
            contentWidth: bigImageID.width
            contentHeight: bigImageID.height
            clip: true
                id: bigImageID
                source: "bigImage.png"
                id: dragHandlerID
                target: null
                acceptedButtons: Qt.RightButton
                        console.log("Drag is activated");
                        console.log("Drag is deactivated");

    With the code above, the console never logs "Drag is activated" or "Drag is deactivated".

  • Hello,

    No one to help ?

    Tks in advance

Log in to reply