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

Drop docx files in Qt on Windows



  • I am trying to make my program get documents like docx, pptx etc when i drop those files in the widget. I need to unpack those files(because docx is zip format). I dont know how to get path to source file for 7z, so i have decided to copy received data to temporary file. But i get empty output file. What is wrong?

    void DragnDropWidget::dropEvent(QDropEvent *event)
    {
        QTemporaryFile docFile("C:/Users/Denis/Documents/Document_XXXXXX.docx");
        docFile.setAutoRemove(false);
        docFile.open();
        docFile.write(event->mimeData()->data("application/x-qt-windows-mime;"
                                                  "value=\"FileContents\""));
        event->acceptProposedAction();
        docFile.close();
    }
    

  • Moderators

    @denix56
    what does open() return?
    Is the data returned from the mimeData() valid?


Log in to reply