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

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 ?:

    ha

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

    ApplicationWindow
    {
        visible: true
        width: 1280
        height: 720
        title: qsTr("Dataxel Model")
    
        Flickable
        {
            id: flickableID
            anchors.centerIn: parent
    
            width: 700
            height: 500
            contentWidth: bigImageID.width
            contentHeight: bigImageID.height
            clip: true
    
            Image
            {
                id: bigImageID
                source: "bigImage.png"
            }
    
            DragHandler
            {
                id: dragHandlerID
                target: null
                acceptedButtons: Qt.RightButton
                onActiveChanged:
                {
                    if(active)
                    {
                        console.log("Drag is activated");
                    }
                    else
                    {
                        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