Search code examples
qtwidgetqgraphicsviewqgraphicsscene

QT - MAXIMIZE QGraphicsScene SIZE


I am using Ubuntu. I need to rotate of 90 grades my 600x800 mainwindow to get it with size 800x600.

Here is my code:

setGeometry(0,0,600,800);
//...
scene = new QGraphicsScene();
view = new QGraphicsView();
proxy = new QGraphicsProxyWidget();
proxy = scene->addWidget(this);
view->setScene(scene);
view->rotate(90);
view->show();

My mainwindow appears now rotated properly, but I get both vertical and horizontal scrollbars, and only a portion of my 800x600 is visible, like in picture.

enter image description here

qDebug() << this-> width(); //800
qDebug() << this-> height(); //600

Adding the following code, scrollbars disappear, but my mainwindow STILL NOT BE MAXIMIZED, like in picture

view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

enter image description here

Adding code like:

view->setGeometry(0,0,800,600);
view->setMinimumWidth(800);
view->setMinimumHeight(600);

seems to change nothing.


Solution

  • view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setFixedSize(800,600);
    

    It works!