Results 1 to 4 of 4

Thread: [solved]drag a picture to a different application

  1. #1
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default [solved]drag a picture to a different application

    hi
    I want to drag a picture to a different application (f.e. gimp). It works fine with that code:
    Qt Code:
    1. QMimeData* mimedata = new QMimeData;
    2. mimedata->setImageData(QImage("/home/user/picture.jpeg"));
    3. QDrag *drag = new QDrag(this);
    4. drag->setMimeData(mimedata);
    5. QPixmap& pic = *picture;
    6. drag->setPixmap(pic);
    7. drag->exec(Qt::MoveAction);
    To copy to clipboard, switch view to plain text mode 
    But there is a problem. The picture is in the application, but it doesn't point to the picture on the file system. It's just a paste command. Does anybody know what I have to do?

    thanks
    Last edited by Qiieha; 20th June 2011 at 09:31.

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: drag a picture to a different application

    Perhaps you should try to pass the file name, not the image itself.

  3. The following user says thank you to Rachol for this useful post:

    Qiieha (20th June 2011)

  4. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: drag a picture to a different application

    Try adding:
    Qt Code:
    1. mimedata->setUrls( QList<QUrl>() << QUrl::fromLocalFile( "/home/user/picture.jpeg") );
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to stampede for this useful post:

    Qiieha (20th June 2011)

  6. #4
    Join Date
    Apr 2011
    Posts
    195
    Thanks
    49
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: drag a picture to a different application

    thank u guys!!
    Qt Code:
    1. mimedata->setUrls( QList<QUrl>() << QUrl::fromLocalFile( "/home/user/picture.jpeg") );
    To copy to clipboard, switch view to plain text mode 
    works perfect! great!

Similar Threads

  1. Drag & Drop in MDI application
    By Koas in forum Qt Programming
    Replies: 2
    Last Post: 2nd September 2011, 08:25
  2. Qt move picture per drag and drop
    By Qiieha in forum Qt Programming
    Replies: 0
    Last Post: 14th June 2011, 11:02
  3. Replies: 2
    Last Post: 2nd December 2010, 10:06
  4. drag and drop from outside qt application
    By elflord in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2009, 15:40
  5. Drag and drop outside the application
    By jpn in forum Newbie
    Replies: 7
    Last Post: 27th August 2006, 15:37

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.