Results 1 to 15 of 15

Thread: QGraphicsScene and dropEvent

  1. #1
    Join Date
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QGraphicsScene and dropEvent

    I want my GraphicsScene to receive drop events, but it does not seem to work. I can set an item inside my scene to receive drops, but not the scene itself.

    What am I failing to read?

  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: QGraphicsScene and dropEvent

    Did you reimplement dragEnterEvent() and/or dragMoveEvent() for the scene?
    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
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene and dropEvent

    I did dragEnterEvent, but then all I get is a reaction when I drag into the scene and nothing when I drop into the scene. I have not tried dragMoveEvent. I have tried dropEvent and that is not working for the scene.

  4. #4
    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: QGraphicsScene and dropEvent

    dragEnterEvent() itself is not enough as the default dragMoveEvent() will ignore drags for areas not occupied by items.
    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.


  5. The following user says thank you to wysota for this useful post:

    prof.ebral (5th March 2010)

  6. #5
    Join Date
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene and dropEvent

    I tried that after I read your post, Wysota. I apologize, I should have updated my status on the thread.

    After I reclass both of those, is there a third step that I am missing?

  7. #6
    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: QGraphicsScene and dropEvent

    Quote Originally Posted by prof.ebral
    After I reclass both of those
    Would you care to explain what you mean by that?
    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.


  8. #7
    Join Date
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene and dropEvent

    Sorry. I meant re-implement. In PyQt I just add the function to the class when the event occurs the function is called.

  9. #8
    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: QGraphicsScene and dropEvent

    And what did you put in those reimplementations?
    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.


  10. #9
    Join Date
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene and dropEvent

    just print statements so I could determine if they are working.

  11. #10
    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: QGraphicsScene and dropEvent

    That's not enough. You have to make sure those events are accepted.
    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.


  12. #11
    Join Date
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene and dropEvent

    How do I determine that?

  13. #12
    Join Date
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene and dropEvent

    I think I have stumbled on to part of my problem. If I reimplement dropEvent in the GraphicsView, that reimplementation takes precedence over my Scene, and any items in that Scene. If I reimplement dropEvent in my Scene, that takes precedence over any items in the scene.

    What I need is a decision making process so the dropEvents can be sent to the correct reimplementation.

  14. #13
    Join Date
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene and dropEvent

    ok .. I looked over the Graphics View Framework again and this is the way I understand it. GraphicsView events are called first and are then forwarded to the scene. Scene events events then forward the event to the Item.

    Because of this framework it sounds impossible to actually drag and drop an item onto a Scene or a View, I would need to have an Item to accept that dropEvent. Is that correct? Is there any way to work around this so I can drop directly onto the Scene or the View?

  15. #14
    Join Date
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsScene and dropEvent

    Oddly Wysota, when I tried what you had recommended it did not work as I thought it would. I reorganized my script so that it is cleaner and tried again. Thanks!

  16. #15
    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: QGraphicsScene and dropEvent

    [QUOTE=prof.ebral;135171Because of this framework it sounds impossible to actually drag and drop an item onto a Scene or a View, I would need to have an Item to accept that dropEvent. Is that correct? Is there any way to work around this so I can drop directly onto the Scene or the View?[/QUOTE]

    You can always call the base class implementation of the event to "forward" the drop from the view to the scene and then to the item.
    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: 8
    Last Post: 15th September 2021, 06:35
  2. dropEvent doesn't happen without mousemove
    By Dimon in forum Qt Programming
    Replies: 0
    Last Post: 6th October 2009, 16:49
  3. Replies: 1
    Last Post: 15th August 2009, 11:23
  4. Advice catching dropEvent
    By DirtyBrush in forum Qt Programming
    Replies: 5
    Last Post: 15th July 2009, 16:43
  5. Drag and Drop, dropEvent not being called?
    By steg90 in forum Qt Programming
    Replies: 36
    Last Post: 22nd May 2007, 07:03

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.