Results 1 to 3 of 3

Thread: Qgraphicsitem drag and drop

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2012
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qgraphicsitem drag and drop

    i have a problem with qt i want to drag an image and use of Qgraphicspixmapitem and dragenterevent but it doesnt appear in the console ? but other function like hoverEnterEvent work corectly??? hear is the code: please help?
    :
    Qt Code:
    1. #ifndef BUTTON_H
    2. #define BUTTON_H
    3.  
    4. #include <QGraphicsObject>
    5. #include <QGraphicsPixmapItem>
    6. #include <QPixmap>
    7. #include <QGraphicsSceneMouseEvent>
    8. #include <QGraphicsSceneHoverEvent>
    9. #include <QDrag>
    10.  
    11. class button : public QGraphicsPixmapItem
    12. {
    13. public:
    14. button(const QPixmap &);
    15. button(){setAcceptHoverEvents(1);
    16. setAcceptDrops(true);}
    17. void changepic( QPixmap,int ,int);
    18. void mousePressEvent(QGraphicsSceneMouseEvent*event);
    19. void dragenterEvent(QGraphicsSceneDragDropEvent *event){
    20.  
    21. event->setAccepted(1);
    22. qDebug("drag");
    23. }
    24. void dropEvent(QGraphicsSceneDragDropEvent *event){
    25. qDebug("drop");
    26. }
    27.  
    28. void hoverEnterEvent(QGraphicsSceneHoverEvent *event){
    29.  
    30. // do something
    31. // this->setPos(this->x()+10,this->y()+10);
    32.  
    33. qDebug("k");
    34.  
    35. QGraphicsItem::hoverMoveEvent(event);
    36. }
    37. void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    38.  
    39.  
    40.  
    41. };
    42.  
    43. #endif // BUTTON_H
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 8th June 2012 at 22:21. Reason: missing [code] tags

Similar Threads

  1. Replies: 0
    Last Post: 7th January 2012, 16:20
  2. Replies: 2
    Last Post: 13th October 2010, 22:51
  3. Handle Drag & Drop Events with QGraphicsItem [SOLVED]
    By guilugi in forum Qt Programming
    Replies: 2
    Last Post: 13th July 2010, 19:05
  4. Replies: 0
    Last Post: 4th May 2010, 11:24
  5. Drag-Drop in QGraphicsItem
    By zgulser in forum Qt Programming
    Replies: 1
    Last Post: 10th September 2009, 21:27

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