I'm inserting a QWidget into the item with QTreeWidget::setItemWidget().

But after moving the item with the code below, the widget disappears:
Qt Code:
  1. tree->insertTopLevelItem( newindex, tree->takeTopLevelItem( index ) );
To copy to clipboard, switch view to plain text mode 
Calling setItemWidget() again does not help.
What is more, application crashes when trying to access the widget which was previously inserted to that item.
Documentation says nothing about these issues.

How do I move items in QTreeWidget while keeping their inserted widgets?