Qt what needs to be done for a custom model to enable drop?

喜你入骨 提交于 2019-12-05 22:49:29

Finally figured this one out on my own.

Turns out the issue was that in the flags function, in the case of invalid indexes I had failed to return the ItemIsDropEnabled flag. An invalid index is the signal for the root node, i.e. the area of the view where there were no items, and so the empty space was not droppable.

This had been hard to detect because I had been trying to use drop to add items to my tree, and so there were none without drop working, meaning all I saw was the circle with a slash.

For those facing similar problems, I want to point out that it is necessary to return Qt::CopyAction among the supported drop actions. Qt::MoveAction alone will not work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!