Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How do I find out which item has been drag'n'dropped?



  • I have a QTreeView control with dragging enabled (I drop it on my custom control). While dropping I need to know what item from QTreeView was dragged. How do I find it out?


  • Moderators

    you need to subclass your model:
    @
    QMimeData *MyModel::mimeData(const QModelIndexList &indexes) const
    {
    QMimeData * mimeData = QAbstractItemModel::mimeData(indexes);
    mimeData->setData(...); //set your mime-data which you can read in your drop-event
    return mimeData;
    }
    @


Log in to reply