Results 1 to 2 of 2

Thread: How to get current drag item?

  1. #1
    Join Date
    Apr 2012
    Location
    Georgia/Rustavi
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to get current drag item?

    Hi guys.

    I have a few questions about drag & drop.

    How can I get current drag item in QMimeData?

    I have the code:

    Qt Code:
    1. void qet::dragEnterEvent(QDragEnterEvent *event)
    2. {
    3. if(event->mimeData()->hasFormat("text/uri-list"))
    4. event->acceptProposedAction();
    5. else if(event->mimeData()->hasFormat("image/*"))
    6. event->acceptProposedAction();
    7. }
    8. //--------------------------------------------------------------
    9. void qet::dropEvent(QDropEvent *event)
    10. {
    11. //ui->textEdit_2->setText (event->mimeData()->text());
    12. QMimeData *mime =new QMimeData;
    13. mime->setImageData(QImage("/home/programmer/Documents/qet/images/cute.jpg"));
    14. QPixmap pix(200,200);
    15. QPainter painter(&pix);
    16. QImage image = qvariant_cast<QImage>(mime->imageData());
    17. painter.drawImage(rect(),image);
    18. ui->label_3->setPixmap(pix);
    19. event->acceptProposedAction();
    20. }
    To copy to clipboard, switch view to plain text mode 


    And, when some image is dragged mainwindow, there is always 1 image, I can't get "current dragging image".

    where can I save that, in what kind of buffer, and how to do that in my situation

    p.s sorry for pure English.

    Thanks and best regards from me.
    I'm not here, not in this world. I'm in the astral part of my mind.
    I'm half dead.

  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: How to get current drag item?

    QDropEvent::mimeData() contains the item being dragged.
    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. Replies: 0
    Last Post: 10th March 2011, 11:44
  2. bg color of current item for a QTreeView
    By joeld42 in forum Qt Programming
    Replies: 1
    Last Post: 18th October 2009, 17:06
  3. get and set current item in QTableView
    By pospiech in forum Newbie
    Replies: 8
    Last Post: 25th May 2009, 13:25
  4. current item in treeview
    By kernel_panic in forum Qt Programming
    Replies: 2
    Last Post: 30th October 2007, 19:26
  5. get current item from QCompleter
    By evgenM in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 18:16

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.