Results 1 to 2 of 2

Thread: drag&drop from QTreeWidget to QGraphicsPixmapItem

  1. #1
    Join Date
    Jul 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default drag&drop from QTreeWidget to QGraphicsPixmapItem

    Hi, I want to drag a QTreeWidgetItem from my QTreeWidget to the QGraphicsPixmapItem.
    Do I have to reimplement mouse events in the drag site.
    I reimplemented them such as
    Qt Code:
    1. mousePressEvent(QGraphicsSceneMouseEvent *e);
    2. mouseMoveEvent(QGraphicsSceneMouseEvent *e);
    3. mouseReleaseEvent etc..
    To copy to clipboard, switch view to plain text mode 
    but the program flow never falls into the mouse events in debug mode.
    I have also performed setAcceptDrops(true) in my QGraphicsPixmapItem's constructor and reimplemented the dropEvent( QDropEvent *event ) but again the flow never falls inside it.

    How will I be able to perform the drag & drop?
    My aim is to send the currently dragged QTreeWidgetItem's text to the QGraphicsPixmapItem.

    Best regards.

  2. #2
    Join Date
    Jun 2010
    Posts
    4
    Qt products
    Qt4 Qt/Embedded PyQt3 PyQt4
    Platforms
    MacOS X Windows

    Default Re: drag&drop from QTreeWidget to QGraphicsPixmapItem

    Before starting to debug make you sure you have these things set properly:

    - A correct Start of a drag operation (enable dnd and reimplement the necessary event handler i can send you to this link http://doc.qt.nokia.com/4.6/dnd.html

    ad this one

    http://web.njit.edu/all_topics/Prog_...d-example.html



    -The QGraphicsView container where you want to drop your item is interactive with : ( void QGraphicsView::setInteractive ( bool allowed ) ).

    - The QGraphicsView container where you want to drop your item accept drop events with : QGraphicsView::setAcceptDrops(true);

    - if you're subclassing QGraphicsPixmapItem set your class it to accept drop with : void QGraphicsItem::setAcceptDrops ( bool on )

    then reimplement

    dropEvent ( QGraphicsSceneDragDropEvent * event ) of your subclass and process the data contained in the event->mimeData().

    This data (the text ) should be loaded in the start drag processing.

Similar Threads

  1. QTreeWidget Drag and drop
    By zell99 in forum Newbie
    Replies: 15
    Last Post: 7th August 2010, 13:28
  2. QTreeWidget: Drag and Drop
    By laugusti in forum Qt Programming
    Replies: 0
    Last Post: 11th June 2010, 15:37
  3. QtreeWidget drag and drop
    By addu in forum Qt Programming
    Replies: 4
    Last Post: 30th June 2009, 09:41
  4. QTreeWidget Drag and Drop
    By tommydent in forum Qt Programming
    Replies: 10
    Last Post: 25th August 2008, 15:25
  5. QTreeWidget drag/drop
    By s_a_white in forum Newbie
    Replies: 1
    Last Post: 10th February 2007, 22:04

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.