Important: Please read the Qt Code of Conduct -

Qml TreeView select on release

  • Hi guys,

    I want to implement some drag & drop functionality to TreeView but right now the item selection changes while I keep the mousebutton pressed.

    Is there a way to change the way the selection works now?


  • Hi @themts , can you explain me in detail like what you are going to drag and drop and what should happen after you drop that item, and what kind of selection you want.
    If you can show me the code, it would be easier for me understand and help you out.

  • There is no code yet.
    I need to copy items from one node to several other nodes.
    Therefor I would like to handle an onPressAndHold, create a fake-item which is semi-transparent above the treeView.
    While dragging this fake-item over the tree-view I would like to highlight the items which are hovered by mouse so the user knows where he is gonna drop.
    OnRelease I want to check the highlighted item and insert a new sub-element in this treeNode and hide my fake-item.

    The treeView is already working and has a c++-model.

  • @themts , ohh okay,but that's really difficult, inserting a sub-element etc is not a problem as you can handle it in c++, but the drag and drop functionality seems to be a bit diffcult because when you drag the fake-item over the tree view i dont think that you can highlight the currently hovered item because the focus of the mouse is on the fake-item.Please do share the way of implementation if somehow you get to do that, so that it will be helpful for me as well as others.

Log in to reply