Important: Please read the Qt Code of Conduct -

QGLWidget displayed only in QScrollArea

  • Hello

    I have a custom QGLWidget that works fine standalone, and also if I embed it into a QScrollArea, but if I directly add it to the layout or embed it into a QWidget, it won't get displayed, it won't even take up its place in the UI. I call the resize after construction.
    I tried it several ways but nothing worked (except the scrollarea)
    My current code looks like this:
    MapArea *wtf = new MapArea();
    QWidget *sa = new QWidget();
    QHBoxLayout *gl = new QHBoxLayout;
    wtf->resize(640, 480);
    QTextEdit *te = new QTextEdit();
    QGridLayout *centralPartLayout = new QGridLayout();
    centralPartLayout->addWidget(sa, 1, 1);
    centralPartLayout->addWidget(te, 1, 2);

    Please tell me how should I add the widget to the layout.


  • What do you mean by: "won't get displayed"?

  • I doesn't take up its place in the layout. Maybe the resize operation is ineffective.
    On "this picture": it should be above the middle textedit

  • Check if the problem is with incorrect size policy.

  • Resizing the square in the grid after the QGLwidget was added solved the problem.
    I called setColumnMinimumWidth and setRowMinimumHeight, but I don't know why is this needed...

Log in to reply