Results 1 to 2 of 2

Thread: Drag outlook attachment to Qt Application

  1. #1
    Join Date
    Jul 2011
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Drag outlook attachment to Qt Application

    Im testing my drag&drop classes, so far im able to drop files, text and gmail attachments into my application, BUT when i try to drag an attachment from an Outlook email, i get nothing.

    Qt Code:
    1. void MainWindow::dragEnterEvent(QDragEnterEvent *event)
    2. {
    3. qDebug() << "Format: " << event->format() ;
    4. qDebug() << "Supported formtas: " << event->mimeData()->formats().join(",");
    5.  
    6. if (event->mimeData()->hasHtml() ||
    7. event->mimeData()->hasText() ||
    8. event->mimeData()->hasUrls() ||
    9. event->mimeData()->hasFormat("application/x-qt-windows-mime;value=\"Shell IDList Array\"") ||
    10. event->mimeData()->hasFormat("application/x-qt-windows-mime;value=\"FileName\"") ||
    11. event->mimeData()->hasFormat("application/x-qt-windows-mime;value=\"FileNameW\"") ||
    12. event->mimeData()->hasFormat("application/x-qt-windows-mime;value=\"FileGroupDescriptorW\""))
    13. {
    14. event->acceptProposedAction();
    15. activateWindowDrop();
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    here's what i get when i drag the attachment:
    Format: application/x-qt-windows-mime;value="FileGroupDescriptorW"
    Supported formtas: "application/x-qt-windows-mime;value="FileGroupDescriptorW",application/x-qt-windows-mime;value="FileGroupDescriptor",application/x-qt-windows-mime;value="RenPrivateItem",application/x-qt-windows-mime;value="FileContents""


    I thought that the local url of the attachment would be stored in the getUrls(), so i tried:
    Qt Code:
    1. void MainWindow::dropEvent(QDropEvent *event)
    2. {
    3. if (event->mimeData()->hasText())
    4. qDebug() << "Text: " << event->mimeData()->text();
    5. else
    6. {
    7. foreach (QUrl url, event->mimeData()->urls())
    8. qDebug() << url.toLocalFile();// empty
    9.  
    10. QByteArray data = event->mimeData()->data("FileGroupDescriptorW");
    11. qDebug() << QString::fromUtf16((ushort*)data.data(), data.size() / 2); // "r"
    12. qDebug() = event->mimeData->data("FileName");//empty
    13. qDebug() = event->mimeData->data("FileContents");//empty
    14. qDebug() = event->mimeData->data("RenPrivateItem");//empty
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    Anyone knows how to do this? i've tried draggin a .RAR file, as well as a.DOCX, and is the same.

    Thanks!

  2. #2
    Join Date
    Jul 2011
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drag outlook attachment to Qt Application

    OK, so i found the solution.
    The kind of mime format that i get when draggin an outlook attachment is "application/x-qt-windows-mime;value="FileGroupDescriptorW""
    I have no url or filename, but i can get the content of the attachment via event->mimeData->data("FileContents");
    Then i write that into a QFile and i am ready to go and do something with that file.

    Bye.

Similar Threads

  1. Link specify on outlook mail....
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 12
    Last Post: 11th October 2011, 00:59
  2. How to open Outlook using Qt
    By votinh in forum General Programming
    Replies: 2
    Last Post: 21st June 2010, 16:13
  3. Outlook problem
    By GianMarco in forum Qt Programming
    Replies: 1
    Last Post: 18th October 2009, 17:02
  4. Replies: 4
    Last Post: 17th June 2007, 10:30

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.