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.
Thanks for the help. It worked.
MyTreeWidget::MyTreeWidget( QWidget* aParent /*= nullptr*/ )
: QTreeWidget( aParent )
{
// ...
auto rooItem = invisibleRootItem();
rooItem->setFlags( rooItem->flags() ^ Qt::ItemIsDropEnabled );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With