简体   繁体   中英

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.

在此处输入图片说明

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);

在此处输入图片说明

Adding code like:

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

seems to change nothing.

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

It works!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM