Important: Please read the Qt Code of Conduct -

QT3D in a form

  • Hi

    I'm developing desktop application that include a widget to display 3D models (3D viewer). I would like to use QT3D to render the model. In my form I have included a widget that is implemented in a class with heritage of a QWidget.

    This is the .h of widget object

        Display3D(QWidget *parent = 0);
    private : 
         QWidget *container;
    //your code here
    This is the cpp of the QWidget ( mostly the constructor. This is only interesting implementation for now 
      // Root entity
        Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity();
        auto view = new Qt3DExtras::Qt3DWindow();
        QSize sWidget = this->size();
        qInfo() << "widget size " << sWidget.width() << " " << sWidget.height();
        // create a container for Qt3DWindow
        container = createWindowContainer(view,this);
        // background color
        // background color
         // Camera
           Qt3DRender::QCamera *cameraEntity = view->camera();
    //your code here

    When I run the application the GUI appear and display in the widget the shape I would like to draw (not in the current code). The issue is the 3D display is super small in the top left corner of the area of my widget. It is like I have created a window in my widget. How I can have the 3D view occupy the entire widget surface?

    Thank you

Log in to reply