What is the real effect of function: QGraphicsScene::setSceneRect?
-
#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsView>int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setFixedSize(800, 600);
view.show();
scene.setSceneRect(100, 100, 300, 300);
// scene.setSceneRect(0, 0, 300, 300);
//scene.setSceneRect(-100, -100, 300, 300);
scene.addRect(0, 0, 300, 300, QPen(Qt::blue));
scene.addRect(0, 0, 1, 1, QPen(Qt::red));
return a.exec();
}Changing the arguments of setSceneRect, I see the red point and the blue rectangle is positioned on different points in the window, why? Can you help me? I read the Qt documents about "Graphics View Framework" and QGraphicsScene, QGraphicsView, QGraphicsItem, Coordinates, ... but I cannot imagine why changing the positions make those items changing the positions in the window/view.
-
Hi,
From the doc, I'd say that the items are still put at the same global places but your scene is looking at a different place in the global scene.