I have an application composed from graphics view and graphics scene. The basic GUI structure is this (done in Qt Creator):
QMainWindow
QWidget (centralWidget)
QGridLayout
QVBoxLayout
QGraphicsView
This is my code for the mainwindow constructor:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
{
ui->setupUi(this);
scene = new Scene(this);
ui->graphicsView->setScene(scene);
scene->setSceneRect(-100,-100,200,200);
}
Now when I manually resize the application window, visually the scene/graphics view resizes too. It is also active in all the visible area, I can catch mouse events, add items there, although it is out of the region set by setSceneRect()
. But when I call scene->width()
or scene->height()
, it returns 200 all the time. How can I get the size of the visible part of the scene and not the size set in setSceneRect()
? By the visible part of the scene I mean the white visible area/rectangle where my items are visualized, if the item goes out of this area, it is not visible.