Results 1 to 2 of 2

Thread: QMimeData using setText and setUrls at the same time

  1. #1
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Default QMimeData using setText and setUrls at the same time

    I have a list widget that contains file paths. I want to be able to drag and drop the list widget items to external applications.

    For instance, I would drag an item to the desktop and it would copy the file to the desktop. If I drag it to thunderbird's text area it would paste in the path to the file.

    Here's what I have:

    Qt Code:
    1. QMimeData * ListWidget::mimeData(const QList<QListWidgetItem *> items) {
    2. QList<QUrl> urls;
    3. urls.append("file:///foo/bar/baz.txt");
    4. urls.append("file:///foo/bar/xyx.txt");
    5.  
    6. QString text;
    7. text = "file:///foo/bar/baz.txt file:///foo/bar/xyx.txt";
    8.  
    9. QMimeData * data = new QMimeData();
    10. data->setText(text);
    11. data->setUrls(urls);
    12. return data;
    13. }
    To copy to clipboard, switch view to plain text mode 

    The weird thing is, when I drag the item onto thunderbird, it interleaves the two, so I'll get something like this:

    'file:///foo/bar/baz.txt' 'file:///foo/bar/xyx.txt''file:///foo/bar/baz.txt 'file:///foo/bar/xyx.txt'

    Calling just setUrls, thunderbird wont even accept the drop event over the text area, just as an attachment. I'm wondering if I'm just doing this the wrong way, or if this is a bug in thunderbird, as well as other applications. Similar things happen dragging to the Gnome Terminal.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMimeData using setText and setUrls at the same time

    The target application should choose one mime-type to handle, not all of them. If it handles more than one type then I'd say that's a bug (or a feature) in this particular application.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How to use QMimeData::setHtml?
    By Vadi in forum Qt Programming
    Replies: 4
    Last Post: 25th January 2011, 16:52
  2. Replies: 3
    Last Post: 22nd March 2010, 13:50
  3. Drag&Drop - Pointer into QMimeData?
    By droetker in forum Newbie
    Replies: 2
    Last Post: 11th October 2009, 14:14
  4. Is there a known problem with QMimeData on Mac OS X?
    By Wurgl in forum Qt Programming
    Replies: 8
    Last Post: 27th February 2008, 22:21
  5. MIME database and QMimedata
    By nupul in forum Qt Programming
    Replies: 12
    Last Post: 12th April 2006, 14:36

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.