Results 1 to 3 of 3

Thread: Qgraphicsitem drag and drop

  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 21:21. Reason: missing [code] tags

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

    Default Re: Qgraphicsitem drag and drop

    There is a difference between dragenterEvent and dragEnterEvent.
    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.


  3. #3
    Join Date
    Jun 2012
    Posts
    12
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qgraphicsitem drag and drop

    hi everyone

    can anybody give me a simple example that i can drag and drop QGraphicsItem by using of :

    void dragEnterEvent(QGraphicsSceneDragDropEvent *event)
    very thanks.

Similar Threads

  1. Replies: 0
    Last Post: 7th January 2012, 15:20
  2. Replies: 2
    Last Post: 13th October 2010, 21:51
  3. Handle Drag & Drop Events with QGraphicsItem [SOLVED]
    By guilugi in forum Qt Programming
    Replies: 2
    Last Post: 13th July 2010, 18:05
  4. Replies: 0
    Last Post: 4th May 2010, 10:24
  5. Drag-Drop in QGraphicsItem
    By zgulser in forum Qt Programming
    Replies: 1
    Last Post: 10th September 2009, 20: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.