Solved QMainWindow.resize prevent QGraphicsView.resize
-
QMainWindow.resize will auto resize QGraphicsView to fit parent, how to prevent ?
void MainWindow::open(QString filepath) { scene->clear(); QPixmap pixmap(filepath); QGraphicsPixmapItem *GPI = scene->addPixmap(pixmap); GPI->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable); scene->setSceneRect(0, 0, pixmap.width(), pixmap.height()); ui->graphicsView->resize(pixmap.size()); }
-
@sonichy
If your QGraphicsView is inside a QLayout, this layout automatically position and resize all child widgets.
But you can break the resize feature by setup a fixed Size of a widget.setFixedHeight(int h)
setFixedWidth(int w)
setFixedSize(const QSize &s)
setFixedSize(int w, int h)
-
@KillerSmath Yes, child widget with no layout will be not auto resize with parent !
But the scrollbar do not display !