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

MS Windows QWidget virtual files from QDropEvent's mimeData()



  • Hi,

    when dropping for example an e-mail message from Microsoft Outlook to a QWidget the resulting QDropEvent / mimeData() does not fetch the actual .msg file data. I know there are some articles/threads on other sites on this topic, e.g. on MSDN, but I don't understand how to connect this with a QWidget drop event, plus it makes use of MAPI which is not ideal, because it is not a generic approach. This C# example does exactly what I want to achieve without MAPI, but depends on DotNet, but obviously I'm using Qt5/C++. I also read, that there is an abstract class in WinExtras QWinMime which is supposed to "convert" certain Windows specific Clipboard formats, but I can't find any information on implementing concrete classes or how to use within a dropEvent. Can someone help please?

    void DragDropTest::dropEvent(QDropEvent *event) {
        QByteArray fileDescriptor = event->mimeData()->data(QLatin1Literal("application/x-qt-windows-mime;value=\"FileGroupDescriptorW\""));
        // how to process fileDescriptor (or other mime data that is provided here) to get the file data
    }
    

  • Moderators

    @thecodemonkey
    I had the same problem once. Its not solvable via Qt. You will need to use WinAPI to access the drop data and this requires a pointer to the drop-handle pointer IIRC. But this is hidden in the Qt internals and required a change to the Qt source code to be able to handle this in the dropEvent() handler.

    There is also a bugreport regarding the missing ability to handle FileContents/FileGroupDescriptor mime-types, but i can't find it though.


Log in to reply