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

How do I identify Drag & Drop sources across multiple QtQuick ListView controls.



  • Hi:

    I'm doing some prototyping use QtQuick ListViews.
    I have 3 lists defined and am implementing Drag and Drop between those lists.
    There are some "rules" I would like to implement.

    1. Item from List1 can be dropped onto List 2 and List3

    2. Item from List2 can be dropped onto List3, but not List1

    3. When an item is an item is dropped onto List3, I would like to be identify the source and
      update the associated ListModel

    4. An Item from List can be dropped onto itself and the result should put the item into a different position with the list.

    5. When an item is hovering over a destination, I would like to have a visual indicator differentiating between an allowable/disallowable destination..

    Currently I have this small QML code snippet that handles 1 way Drag&Drop between 2 ListViews:

    DropArea {
               id: dropArea1
               anchors.fill: parent
               onDropped: {
                    var item = listView.model.get(listView.dragItemIndex);
                     listView1.model.insert(0, item)
                     listView.model.remove(listView.dragItemIndex);
                     listView.dragItemIndex = -1;
                }
    }
    

    I would like to be able to handle this functionality through QML.
    Can someone help me with answers for these questions?

    Thanks,
    JohnB


Log in to reply