What you mean you can't insert the items?
Does the line indicator appear but nothing happens?
This works fine for me:
MainWindow
::MainWindow( QWidget* p
) :
{
tree->setDragEnabled( true );
tree->setAcceptDrops( true );
tree->setDropIndicatorShown( true );
tree->setDefaultDropAction( Qt::MoveAction );
for( int i = 0; i < 5; i++ )
{
root
->setText
( 0,
"root" + QString::number( i
) );
for( int j = 0; j < 5; ++j )
{
leaf
->setText
( 0,
"Leaf " + QString::number( j
) );
}
}
this->setCentralWidget( tree );
}
MainWindow::MainWindow( QWidget* p )
:
QMainWindow( p )
{
QTreeWidget* tree = new QTreeWidget( this );
tree->setDragEnabled( true );
tree->setAcceptDrops( true );
tree->setDropIndicatorShown( true );
tree->setDefaultDropAction( Qt::MoveAction );
for( int i = 0; i < 5; i++ )
{
QTreeWidgetItem* root = new QTreeWidgetItem( tree->invisibleRootItem() );
root->setText( 0, "root" + QString::number( i ) );
for( int j = 0; j < 5; ++j )
{
QTreeWidgetItem* leaf = new QTreeWidgetItem( root );
leaf->setText( 0, "Leaf " + QString::number( j ) );
}
}
this->setCentralWidget( tree );
}
To copy to clipboard, switch view to plain text mode
See if this example has the same issue you're experiencing.
You may need to upgrade it to use mime types, if you do and are able to replicate the issue - post the code here.
Bookmarks