PDA

View Full Version : QTreeWidget addChild/addTopLevelItem/drop lost selection



Alundra
7th February 2015, 05:12
Hi all,
When drag and drop in a QTreeWidget the selection is lost, same for a move to root like that :

ParentItem->treeWidget()->addTopLevelItem( ParentItem->takeChild( ParentItem->indexOfChild( Item ) ) );
The selection is lost using addChild too :

ParentItem->addChild( Item->treeWidget()->takeTopLevelItem( Item->treeWidget()->indexOfTopLevelItem( Item ) ) );
Does I have to disable event of selectionChanged and reselect manually which is a hack or Qt has something to solve the problem ?
Thanks for the help

Alundra
7th February 2015, 15:32
The only solution I found which is ugly :


CMainEditorWindow::GetUndoStack()->push( DropCommand );
blockSignals( true );
QTreeWidget::dropEvent( e );
for( int i = 0; i < SelectedItems.size(); ++i )
SelectedItems[ i ]->setSelected( true );
blockSignals( false );