Important: Please read the Qt Code of Conduct -

QTreeWidget - multiple columns d&d

  • I have a QTreeWidget with tree columns:

    @void MyTree::AddNewElement()
    QTreeWidgetItem* treeItem = new QTreeWidgetItem( this, 0 );
    treeItem->setText( 0, "someText" );
    setItemWidget( treeItem, 1, new QToolButton( this ) );
    setItemWidget( treeItem, 2, new QToolButton( this ) );

    for this widget I want to implement d&d so all the columns should keep their content. Right now when I'm d&d only the text column keeps the content. How should I do it right?


  • Drag'n'drop for item widgets is not supported out of the box.

    You would have to go with QTreeView and a customized model to make this work.

  • yes you're right about this, I need to do some more studying :) , I found a nice example "here":

  • Does setting the following work?


  • Looking at the source code of the Qt libs, the widgets (resp. their pointers) plainly don't make their way into the dragged data.

Log in to reply