QGraphicsScene changes visible area when scenerect changes
Hi,
when i click into the graphicsView with the following example a QGraphicsEllipseItem will be added.
My problem is that the already existing QGraphicsEllipseItems seem to "mov"e each time when a new item is added.
I want the visible are of the scene to be fixed.
When i set the scene rect to a fixed rect, the items stay in position, but then the scene rect is not correct.
I want the sceneRect to include all items and thad the visible area of the scene stays fixed when i add new items.
Can anyone help?
Code:
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QApplication>
#include <QGraphicsEllipseItem>
#include <QMouseEvent>
#include <QPointF>
public:
QPointF pos
= mapToScene
(event
->pos
());
}
};
int main(int argc, char **argv) {
MyView v;
v.setScene(&scene);
v.show();
return app.exec();
}
Re: QGraphicsScene changes visible area when scenerect changes
You could try to set the view's resize anchor to NoAnchor.
Cheers,
_
Re: QGraphicsScene changes visible area when scenerect changes
setting the resize anchor doesn't help. As far as is understand, the resize anchor is only relevent when the QGraphicsView is resized?
When i add items, not the size of the QGraphicsView is changed, but the size of the sceneRect.
Re: QGraphicsScene changes visible area when scenerect changes
Ah, too bad.
Would have been a lucky guess :)
Cheers,
_
Re: QGraphicsScene changes visible area when scenerect changes
ok... i guess its not a big deal if you know how to do it. Any other ideas?