Qt 6.11 is out! See what's new in the release
blog
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(); } -
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(); }@denix56
what does open() return?
Is the data returned from the mimeData() valid?