How to make ViewPort expand with QGraphicsView



  • Good day,
    I've got GraphicsView widget made in Designer. And subclass from QGraphicsView with few new methods. In MainWindow constructor subclass set as ViewPort for GraphicsView. When resize event for mainwindow is called, GraphicsView size changes:

    
    void MainWindow::resizeEvent(QResizeEvent *)
    {
        ui->graphicsView->resize(this->width(), this->height());
    }
    
    

    But i've got some issues with resizing viewport - it stays the same size. What should i do to resize it?
    0_1524120374057_Снимок.PNG

    0_1524120423078_Снимок.PNG

    P.S.: sorry for terrible language.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Did you put your widgets in layouts ?

    You might also be interested by QGraphicsView::fitInView.