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?
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?
Did you reimplement dragEnterEvent() and/or dragMoveEvent() for the scene?
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.
dragEnterEvent() itself is not enough as the default dragMoveEvent() will ignore drags for areas not occupied by items.
prof.ebral (5th March 2010)
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?
Would you care to explain what you mean by that?Originally Posted by prof.ebral
Sorry. I meant re-implement. In PyQt I just add the function to the class when the event occurs the function is called.
just print statements so I could determine if they are working.
How do I determine that?
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.
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?
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!
[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.
Bookmarks