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

(Drag and drop file) How to get destination path?



  • Hello, I made an application can drag and drop files from explorer to application
    and copy files to desktop by drag and drop from application. Here's my code
    @private:
    QMimeData *qmdata;@

    @void Dialog::dropEvent(QDropEvent * event){
    event->accept();
    qmdata=new QMimeData;
    qmdata->setUrls(event->mimeData()->urls());
    }@

    @void Dialog::mousePressEvent(QMouseEvent* event)
    {
    QDrag *drag = new QDrag(this);
    drag->setMimeData(qmdata);
    drag->exec(Qt::CopyAction);
    QDialog::mousePressEvent(event);
    }@

    The problem is, I can't get any information from drag->exec(Qt::CopyAction).
    Can anybody tell me how I can get destination path of copied file by drag and drop?


Log in to reply