After having followed the recommendations given here : QTreeWidget reordering child items by dragging, the dragged item is not selected.
So, quite naturally, I tried to get the dragged item and then call setSelected() on it.
The result is that the item before the correct on is selected.
I subclass QTreeWidget to override dropEvent like this -
QTreeWidgetItem *pItem;
QModelIndex dropIndex = indexAt(pEvent->pos());
if(dropIndex.isValid() == false)
{
pEvent->setDropAction(Qt::IgnoreAction);
pEvent->accept();
return;
}
pItem = this->itemAt(pEvent->pos());
QTreeWidget::dropEvent(pEvent);
How can I get the pointer to the correct QTreeWidgetItem which has been dropped ?