When I add two items to a QGraphicsView with one moveable and the other fixed, the graphics view auto scrolls for a while as it tries to keep both items in view. Of course with a blank background the ‘fixed’ item seems to move too which is not what you want to see when moving just one item.
When the ‘moved item’ moves outside the view window, the auto scrolling stops, and the scroll bars appear.
Is there a way to stop this initial ‘auto scroll’?
So here’s the scenario. Add two items to the scene. One FIXED at (0,0), and another at (5,5) lets say.
Then move the one at (5,5) somewhere and the auto-scroll starts :(
Although perhaps not too relevant, here’s how I add the items to the scene:
//The moveable item
QGraphicsRectItem *rect = new QGraphicsRectItem(0,0,100,50) ;
rect->setFlag( QGraphicsItem::ItemIsMovable, true ) ;
_scene.addItem( rect );
// Some fixed item
_scene.addItem( new QGraphicsRectItem(5,5, 25 , 25) );
ui->graphicsView->setScene(&_scene);
Of course if I change the alignment one can perhaps keep the fixed item at the top left corner in the view – BUT I really want to have the centre point in the centre of the view AND for it to be FIX unless the user moves the scrollbars himself, which by the way are not visible UNTIL an item moves outside the view.
Now, another condition is: I don’t want to have the scrollbars visible by default especially if the scene is entirely visible in the view.
This can probably be solved by just setting some simple flag, i know… BUT… I can’t see it!
Can anyone out there help?
↧