PDA

View Full Version : How to restrict graphic items in view



aamer4yu
10th November 2006, 05:16
I want to know if i can restrict graphics items within a region of the view.:confused:
I want that items should not be moved beyond a point in the view. Is there some inbuilt function to do so ? Or I have to implement my own code for that ??

I have tried setSceneRect, but it just restricts the scrollbars, not dragging of the items.
Also if someone can throw light on setFrameRect ? I didnt understand it much :(
playing with setFrameRect just showed part of the view area, I cudnt get with reference to what the frame rect is set ?

aamer4yu
13th November 2006, 05:12
Can anyone just tell if I have to implement restricting the items myself ??
I have tried various inbuilt functions but withoout the desired effect :(

wysota
13th November 2006, 07:05
Can anyone just tell if I have to implement restricting the items myself ??

Yes, you probably do, but it should be easy - just reimplement mouse move event for your item.

aamer4yu
13th November 2006, 08:24
I will try that...
Before that I was trying dragMoveEvent.

As an example, I built another application, involving a CScene,CView,and CItem , derived from QGraphicsScene, QGraphicsView and QGraphicsItem respectively.
I overrided dragMoveEvent in all three classes. But I find that the program doesnt enter any of the three overloaded functions when I drag an item in the scene :(
In what case is dragMoveEvent called ?? :confused:
and i guess mouseMoveEvent is triggered when I drag an item. Why isnt dragMoveEvent called ??

wysota
13th November 2006, 08:46
drag events are meant for drag&drop operations. You have to specifically enable dragging items for these events to be sent. In "usual" situations you should use mousePress/Move/Release events.