Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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){
         qDebug()<<"bytearrauy"<<by;
     }
    
    if (mimeData->hasImage()) {
        setPixmap(qvariant_cast<QPixmap>(mimeData->imageData()));
    } else if (mimeData->hasHtml()) {
        setText("has html"+mimeData->html());
        setTextFormat(Qt::RichText);
    } else if (mimeData->hasUrls()) {
        QList<QUrl> urlList = mimeData->urls();
        QString text;
        for (int i = 0; i < urlList.size() && i < 32; ++i)
            text += urlList.at(i).path() + QLatin1Char('\n');
        setText("hasurl"+text);
    }
    else if(mimeData->hasFormat("message/rfc822")){
        setText(tr("msg droped"));
    }else {
        setText(tr("Cannot display data"));
    }
    
    setBackgroundRole(QPalette::Dark);
    event->acceptProposedAction();
    

    }


  • Moderators

    @rakm
    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