PDA

View Full Version : DragEnter in GraphicsView



rogerholmes
25th July 2009, 01:00
GraphicsScene *scene =new GraphicsScene(this);

scene->setBackgroundBrush(Qt::red);

myView *gView = new myView(this);
gView->setGeometry(230,20,330,400);

//gView->installEventFilter(this);

gView->setScene(scene);
gView->setSceneRect(0,0,100,100);

gView->setAcceptDrops(true);

i am only able to drop in the right most 1/4 of the view ,i have try'd using QGraphicsview insted of myView , same result. the dragenter will not fire until the right most 1/4 is entered. i am sure i am missing something quite obvious but have read everything i could find pls can somebody point me in right direction.
:)

wysota
25th July 2009, 09:10
Your scene occupies only part of the view - the drops can only occur on the scene, so you get the event not when you enter the viewport but when you enter the rect occupied by the scene.

rogerholmes
25th July 2009, 16:25
Thanks, I thought that was the case , so i colored the scene red , when i setscene(scene), the whole view is red, there are no scroll-bars so i know the scene is smaller than the viewport and the entire view is red, the dropenter is on the myview because i read that this would go through to the scene, am i right in thinking if the scene was not centered, only part of the view would be red and by setting the dragenter/drop etc.. on the myview, wouldn't the event fire when the myview is entered regardless of setting a scene or not? ( i forgot to mention, the myview reacts the same when a scene is not set, only the right 1/4 of the myview fires the dragenter event)

wysota
25th July 2009, 16:53
Thanks, I thought that was the case , so i colored the scene red , when i setscene(scene), the whole view is red,
Do something else. Add a rectangle item occupying the whole scene.


am i right in thinking if the scene was not centered, only part of the view would be red
No, that's wrong. See the idea above.


and by setting the dragenter/drop etc.. on the myview, wouldn't the event fire when the myview is entered regardless of setting a scene or not?
It fires on the graphicsview's viewport and is immediately intercepted by the event filter the view applies on its viewport.


( i forgot to mention, the myview reacts the same when a scene is not set, only the right 1/4 of the myview fires the dragenter event)
That I do not know, maybe that's the way it works if a scene is not set on the view.

rogerholmes
26th July 2009, 02:51
thank you Wysota, i will try what you suggest.:)