After upgrading my Qt 5.3.2 dependency to Qt 5.6, VTK rendering doesn't work anymore.
Here's the 5.3.2 code :
#include <QtWidgets>
#include <QGLWidget>
#include <vtkActor.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderer.h>
#include <vtkSphereSource.h>
#include <QVTKWidget.h>
#include <vtkRenderWindow.h>
int main( int argc, char** argv ){
// create QApplication
QApplication l_app( argc, argv );
// Create widget and layout
QWidget* l_main_widget = new QWidget;
QHBoxLayout* l_main_layout = new QHBoxLayout;
l_main_widget->setLayout( l_main_layout );
// create a QVtkWidget with a simple sphere inside
QVTKWidget* l_view = new QVTKWidget;
l_view->setFixedSize( 300, 300 );
vtkSmartPointer<vtkSphereSource> l_sphere_source = vtkSmartPointer<vtkSphereSource>::New();
vtkSmartPointer<vtkPolyDataMapper> l_sphere_mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
l_sphere_mapper->SetInputConnection( l_sphere_source->GetOutputPort() );
vtkSmartPointer<vtkActor> l_sphere_actor = vtkSmartPointer<vtkActor>::New();
l_sphere_actor->SetMapper( l_sphere_mapper );
vtkSmartPointer<vtkRenderer> l_renderer = vtkSmartPointer<vtkRenderer>::New();
l_renderer->AddActor( l_sphere_actor );
l_view->GetRenderWindow()->AddRenderer( l_renderer );
l_main_layout->addWidget( l_view );
// create a QWebEngineView
QGLWidget* l_gl_widget = new QGLWidget;
l_main_layout->addWidget(l_gl_widget);
l_main_widget->show();
return l_app.exec();
}
I simply updated the QGLWidget to QOpenGLWidget for Qt 5.6 :
QOpenGLWidget* l_gl_widget = new QOpenGLWidget;
And now, my QVTKWidget is simply rendering a black image (see end of post). I already stepped on this thread about making QVTKWidget inherits QOpenGLWidget, but I can't afford to do so, because of QOpenGLWidget & compositing
I've tried to subclass QVTKWidget & some of its methods (PaintEvent & co.) to manually manage its rendering using stuff like vtkGenericOpenGLRenderWindow, but either I'm facing weird problems that I'm still trying to solve, or I'm not skilled enough with these.
Especially, when dealing with QOpenGLContext & QSurfaceFormat, it seems I cannot get them to work with OpenGL 3.2 (which is required by VTK 7 OpenGL2 backend). They seems to be stuck with 2.1 version.
I should mention that I don't have this problem on Windows.
If you've got some clues or help to offer, I would gladly accept.
Last remark: This problem appeared after replacing QWebKit by QWebEngine, which is used in my app, but never displayed at the same time as a VTK view. Yet, as soon as I display a QWebEngineView, all the VTK views of my app stop working.
Thanks for your time :)