PDA

View Full Version : which event/slot get called on scrolling QGraphicsView?



rajesh
20th February 2007, 12:31
1. I want to know starting and ending X position of displayed data on every scroll.
which event get called on scrolling QGraphicsView or QGraphicsScene
where I handle scrolling?
2. can I fix some item in QGraphicsScene, so, it will be displayed on scrolling also?
3.
setFlag( QGraphicsItem::ItemIsMovable );
can I fix to move QGraphicsItem only in X direction not in Y direction?

jpn
20th February 2007, 12:49
1. I want to know starting and ending X position of displayed data on every scroll.
which event get called on scrolling QGraphicsView or QGraphicsScene
where I handle scrolling?

Override QAbstractScrollArea::scrollContentsBy(int dx, int dy).

wysota
20th February 2007, 13:31
2. can I fix some item in QGraphicsScene, so, it will be displayed on scrolling also?
When you scroll the canvas, simply move the item to remain in place (if that is what you want). You can do it in scrollContentsBy() as well.


3. setFlag( QGraphicsItem::ItemIsMovable );
can I fix to move QGraphicsItem only in X direction not in Y direction?

No, you have to subclass the item and reimplement mouseMoveEvent to do that.

rajesh
20th February 2007, 14:02
I going to Override scrollContentsBy(int dx, int dy) (http://doc.trolltech.com/latest/qabstractscrollarea.html#scrollContentsBy).
if it work then I can solve 2nd one also.