Important: Please read the Qt Code of Conduct -

Qt3DExtras: difference between Windows and Linux

  • I am stumbling around trying to get Qt3d functionality in my program. First I was able to get the program to work in Windows, by hijacking code from the basicshapes-cpp example. Now I am trying to get the same program to run under Ubuntu 18.04. The program builds, but executing it generates a crash - Segmentation fault. I have located the line that causes the crash:

    modifier = new SceneModifier(rootEntity);

    The key difference between the example and my code is that I am inserting the container into a QWidget (page), member of a QStackedWidget, previously created with Designer.

    void MainWindow::main3d(QWidget *page)
    Qt3DExtras::Qt3DWindow *view = new Qt3DExtras::Qt3DWindow();
    QWidget *container = QWidget::createWindowContainer(view);
    QSize screenSize = view->screen()->size();
    container->setMinimumSize(QSize(200, 100));
    QWidget *widget = page;
    QHBoxLayout *hLayout = new QHBoxLayout(widget);
    hLayout->addWidget(container, 1);
    (lighting/camera stuff)
    Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect;
    // Root entity
    Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity();
    modifier = new SceneModifier(rootEntity);

    Maybe it shouldn't work in Windows, or else there is a limitation imposed by Linux.

  • Update: I verified that if I start with a very simple UI (I used the calculatorform example UI) with a QWidget added to it that I use to display the scene, my code for setting up the container and SceneModifier works fine. This strongly suggests that the crash I'm getting with my program when I create a SceneModifier is caused by my UI. The UI was elaborated over several years, starting from an extremely limited understanding on the programmer's part, and it is rather complicated and possibly breaks some rules (although it works fine in Qt4).
    Viewing it in Designer where it was created it looks like this:

    MainWindow (QMainWindow)
    ----centralWidget (QWidget)
    --------stackedWidget (QStackedWidget)
    ------------page_input (QWidget)
    ------------page_output (QWidget)
    ------------page_3D (QWidget)
    ----------------sceneWidget (QWidget)
    ------------page_2D (QWidget)
    ------------page_FACS (QWidget)

    sceneWidget is where I am trying to display the 3D scene.

    It has been suggested to me that this should be redone in a simpler way, but each of the 5 pages has a great number of widgets on it, and anyway I wouldn't know how to simplify it.

  • Lifetime Qt Champion

    @gibbogle said in Qt3DExtras: difference between Windows and Linux:


    Did you check what happens inside SceneModifier constructor?

  • @jsulm
    I now have SceneModifier working, when the program is invoked in a terminal. I'm afraid I can't say what it is that I've done that got it to work.

Log in to reply