QTreeView Extended Selection + Drag and Drop

  • Is it possible to keep extended selection for a QTreeView that supports drag and drop?
    If dragDropMode is set to DragDrop, then only one item can be dragged from the QTreeView. Of course I can shift + select then drag, but the requirements of my project is to support both extended selection and drag and drop. So the user would select what they want to drag with extended selection, then click and drag the selected items to start a drag and drop. If the user wants to make a different selection, they would start selecting items that are unselected.

    Thanks in advance.

  • Lifetime Qt Champion


    Just to be sure I understand correctly. You want to:

    • start selection
    • extend selection
    • release mouse button and keyboard
    • move the mouse around
    • come back to tree view
    • start drag and drop with a new click using the current selection
      Is it correct ?

  • @SGaist Yes that's correct. Drag would only be triggered when clicking and dragging selected items. If the items are not selected, then no dragging occurs. The selection would be updated instead.

Log in to reply