I’m trying to migrate my code from Vtk 8.2 to 9.1 using QT 5.15. My main problem is VTK+QT widget. I’ve been using my own VTKQT widget implementation for some years based on QVTKOpenGLNativeWidget.
After updating to VTK9.1 I can create a stand-alone widget (without a parent) and it works fine. But when I try to reparent using “setParent” QT method (as I did without any problems with 8.2) to change the layout in my application it throws “failed at glDeleteFramebuffers 16 Opengl errors detected” and application crashes.
@Michal_Chlebiej hi,michal,has this issue been resolved? I’ve encountered the same problem. My Qt version is 6.5.2, and VTK version is 9.2.6.Below is my minimal code.
qDebug() << "onPushButton";
QWidget* centerWidget = this->centralWidget();
QVBoxLayout* vLayout = nullptr;
QLayout* layout = centerWidget->layout();
if (layout)
{
vLayout = qobject_cast<QVBoxLayout*>(layout);
}
else
{
vLayout = new QVBoxLayout();
centerWidget->setLayout(vLayout);
}
QWidget* parentwidget1 = new QWidget();
QVTKOpenGLNativeWidget* qvtkWidget = new QVTKOpenGLNativeWidget();
QVBoxLayout* vlayout_sub1 = new QVBoxLayout();
vlayout_sub1->addWidget(qvtkWidget);
parentwidget1->setLayout(vlayout_sub1);
vLayout->addWidget(parentwidget1);
parentwidget1->show();
QWidget* parentwidget2 = new QWidget();
QVBoxLayout* vlayout_sub2 = new QVBoxLayout();
vlayout_sub2->addWidget(qvtkWidget);
parentwidget2->setLayout(vlayout_sub2);
The line parentwidget1->show(); is important, if not, it will not appear the error.
Additionally, I only encountered this issue in debug mode. In release mode, with the same code, there are no errors.
I solved the problem just now ! We should resource sharing between the Opengl contexts, and add just one line code before instantiating the QApplication like below: