[vtkusers] Trouble using VTK Widget with QVTK
andyjk
andrewkeeling at hotmail.com
Sun Jul 8 04:36:47 EDT 2018
Thanks
I tried:
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
ui->widget->SetRenderWindow(renderWindow);
This compiles OK, but when I run, it immediately gives the error:
QVTKOpenGLWidget requires a `vtkGenericOpenGLRenderWindow`. `
vtkWin32OpenGLRenderWindow ` is not supported.
because I presume this is the wrong type.
Strangely,
vtkSmartPointer<vtkRenderWindow> renderWindow =
ui->widget->GetRenderWindow();
is allowed, and runs - though it fails to render because I think the context
is wrong (ie in main.cpp I have the line
QSurfaceFormat::setDefaultFormat(QVTKOpenGLWidget::defaultFormat());
which allows me to render in the QVTKpenGLWidget
However,
vtkNew<vtkGenericOpenGLRenderWindow> renderWindow =
ui->widget->GetRenderWindow()
is not allowed by the compiler - telling me that GetRenderWindow() is
expecting a vtkRenderWindow, not an OpenGL one.
So it seems I can create a new OpenGL RenderWindow and set the widget Window
to this :
vtkNew<vtkGenericOpenGLRenderWindow> renderWindow;
ui->widget->SetRenderWindow(renderWindow);
and this gives be the sphere on screen, moveable mouse, but no contour
widget.
But I can't grab the existing render window from the widget, because
vtkSmartPointer<vtkRenderWindow> renderWindow =
ui->widget->GetRenderWindow();
compiles, but fails at runtime (I think due to the mismatch between a
vtkRenderWindow and an OpenGL one), and
vtkNew<vtkGenericOpenGLRenderWindow> renderWindow =
ui->widget->GetRenderWindow()
will not compile because of the perceived type mismatch.
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list