Results 1 to 1 of 1

Thread: dragEnterEvent doesn't work in QGraphicsItem, what's wrong?

  1. #1
    Join Date
    Apr 2011
    Posts
    31
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: dragEnterEvent doesn't work in QGraphicsItem, what's wrong?

    I have a DragDropScene : public QgraphicsScene with drag processing like this:
    Qt Code:
    1. void DragDropScene::dragEnterEvent( QGraphicsSceneDragDropEvent *event )
    2. {
    3. QGraphicsScene::dragEnterEvent(event);
    4.  
    5. if( event->mimeData()->hasFormat( ITEMDRAGMIMETYPE ) )
    6. {
    7. event->acceptProposedAction();
    8. return;
    9. }
    10. event->ignore();
    11. }
    12.  
    13. void DragDropScene::dragMoveEvent( QGraphicsSceneDragDropEvent *event )
    14. {
    15. dragEnterEvent( event );
    16. }
    To copy to clipboard, switch view to plain text mode 

    On this scene I have item with drag processing like this:
    Qt Code:
    1. void ConnectableItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
    2. {
    3. qDebug() << event->pos();
    4. event->ignore();
    5. }
    6.  
    7. void ConnectableItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
    8. {
    9. dragEnterEvent(event);
    10. }
    To copy to clipboard, switch view to plain text mode 

    In constructor of ConnectableItem I have call of
    Qt Code:
    1. setAcceptDrops( true );
    To copy to clipboard, switch view to plain text mode 

    All works except drag processing in ConnectableItem. Functions do not call.


    Added after 1 56 minutes:


    Almost solved. Call to QGraphicsScene::dragMoveEvent(event); needed in DragDropScene::dragMoveEvent(...) with code processing event separetly from dragMoveEvent(). I receive events in ConnectableItem::dragMoveEvent(). But I cannot ignore() them. They are always accepted.
    Last edited by Gourmet; 2nd March 2015 at 14:36.

Similar Threads

  1. QGraphicsItem doesn't update
    By Vyivrain in forum Qt Programming
    Replies: 0
    Last Post: 6th April 2014, 20:51
  2. How to be notified on dragEnterEvent?
    By tuxit in forum Qt Quick
    Replies: 6
    Last Post: 12th August 2011, 13:29
  3. Whats wrong with QList<QGraphicsItem>
    By rubenvb in forum Newbie
    Replies: 6
    Last Post: 22nd January 2010, 20:01
  4. Not getting dragEnterEvent - sometimes
    By derekn in forum Qt Programming
    Replies: 0
    Last Post: 30th October 2009, 07:41

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.