Important: Please read the Qt Code of Conduct -

drag and drop outlook mail item to QT application

  • Hi Team,
    I am trying to drag n drop the mail item from outlook to my local QT application. Drag n drop of .eml extension file is working but the application is not able to detect the mail item when I drag and drop the mail directly from Outlook application installed in MAC Also, I want to fetch the mail body and attachment from the drag n drop event. Please help me with this.
    Attached below is my code snippet:
    void DropArea::dropEvent(QDropEvent *event)
    const QMimeData *mimeData = event->mimeData();

     QList<QByteArray> bytearray=mimeData->dynamicPropertyNames();
     foreach(QByteArray by,bytearray){
    if (mimeData->hasImage()) {
    } else if (mimeData->hasHtml()) {
        setText("has html"+mimeData->html());
    } else if (mimeData->hasUrls()) {
        QList<QUrl> urlList = mimeData->urls();
        QString text;
        for (int i = 0; i < urlList.size() && i < 32; ++i)
            text += + QLatin1Char('\n');
    else if(mimeData->hasFormat("message/rfc822")){
        setText(tr("msg droped"));
    }else {
        setText(tr("Cannot display data"));


  • Moderators

    this is not possible with Qt API (and without modifiying Qt source code) and never will be
    I once implemented this, but only with an ugly hack by exposing the actual drop item out of QtGui dll and examine it's contents directly in the dropEvent() handler.

    Any way you may want to checkout this change though. It may be that it might be possible in the meantime.

Log in to reply