I have a QTreeWidget and I enabled the drag and drop. Despite I would like the users to be able to drag and drop items inside the tree I don't want them to drop any dragged item on the top level. How can I do that ?
Let's say that I have predefined categories which are the top level items and I don't want to extend that list. But in the lower levels the user can create any number of items and also she/he can move those items around.
QTreeWidget::invisibleRootItem
to get root item and disableQt::ItemIsDropEnabled
flag for it. If this doesn't work, reimplement tree widget'sdropMimeData
and block dropping if parent is null or invisible root item. – Pavel StrakhovQStandardItemModel
+QTreeView
for such requests. – Dmitry Sazonov