Important: Please read the Qt Code of Conduct -

QTreeView drag&drop question

  • I've got a (subclass of) QTreeview displaying a list of items and I'd like to be able to drop stuff onto particular items. My view can currently handles the drag/drop events ok, but I don't know how to give visual feedback to the user about which particular item he's about to drop onto. I want to highlight/outline the item under the cursor is under when dragging. What's the right way to do that? Do I have to use a custom ItemDelegate? Can items get dragEnter/dragLeave events? Or do I have to do everything from my QTreeView's dragEnter/Move/Leave event handlers: eg, call indexAt(event->pos()), lookup the item, and manually modify/redraw it?

    It seems like there must be some built-in support for this but I can't seem to find it. Any help greatly appreciated.

Log in to reply