Problem embedding Qt3DWIndow using createWindowContainer in a MainWindow
I would like to use Qt3D in one of my projects but I am a bit stuck with stability problems.
The compiler I am using is MSVC2015 64 bit and I have tried Qt 5.8.0 and 5.9.0 beta and I have different errors when compiling a simple application in which I have embedded a 3D widget using this code in the MainWIndow constructor generated by QtCreator for an application managed by QtDesigner:
ui->setupUi(this); window3d=new Qt3DExtras::Qt3DWindow(); ui->tab->layout()->addWidget(QWidget::createWindowContainer(window3d));
I have added no additional code.
The application crashes randomly mostly when closing it and without any message in Qt 5.8.0 and ,I have the compile-time error "QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined" with Qt 5.9.0 beta.
This happens both in debug an release mode.
Any hint on how to "stabilize" my application or of what am I doing wrong?
Thanks in advance for your help,
It's not a compile-time error, it's a runtime error, and it happens only once at the very first draw of the window.
It goes away if you call
Qt3DWindow::show()right after window creation.
Thanks a lot...of course you are right... It is a runtime error not a compile error... Thanks for the workaround...
I will test it asap...