Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QQuickWidget inside QDockWidget: resize() not working



  • I use a QML with a C++ model.

    My QML is set in a QQuickWidget that I put in a QDockWidget.

    I need sometimes to resize my QDockWidget. However, when I call resize() function, nothing is happening.

    What am I doing wrong ?

    Code example:

    MainWindow::MainWindow() {    
        QQuickWidget *view = new QQuickWidget;
        QQmlContext *ctxt = view->rootContext();
    
        ctxt->setContextProperty("myModel", m_model);
    
        view->setSource(QUrl::fromLocalFile(QML_FILE_DEFINITION));
        view->setGeometry(0, 200, 200, 400);
        view->setResizeMode(QQuickWidget::SizeRootObjectToView);
        view->setMinimumSize(QSize(200,200));
      
        m_dock->setWidget(view); //QDockWidget
        addDockWidget(Qt::LeftDockWidgetArea, m_dock);
    
        m_dock->resize(500,200); //This is not working
        view->resize(500,200); //Not either    
    }

Log in to reply