[vtkusers] How to put Qt widgets on top of a VTK OpenGL scene
Elvis Dowson
elvis.dowson at mac.com
Fri Oct 17 11:27:42 EDT 2008
Hi,
Could you please help me narrow down, as to why using
QGraphicsView with QWidget doesn't work? I just thought I'd try
QVTKWidget in its original form and try to get to render the VTK scene
alone in QVTKWidget that is held by a QGraphicsView.
This gives the identical blank white screen, as when I tried to use
QVTKWidget inherited from QGLWidget. So, I need to first fix the case
where a normal QVTKWidget inherited from QWidget will work.
I just need to host the original QVTKWidget within QGraphicsView,
that's it. How can I do this?
The following code gives me a blank white screen. What am I doing wrong?
Best regards,
Elvis
int main(int argc, char** argv)
{
QApplication app(argc, argv);
// Declare variables
vtkCylinderSource* source = NULL;
vtkPolyDataMapper* mapper = NULL;
vtkActor* actor = NULL;
vtkRenderer* ren = NULL;
// Add support for rendering Qt widgets in an OpenGL scene
GraphicsView view;
QVTKWidget* qvtkWidget = new QVTKWidget(&view);
// Turn off double buffering in the VTK render window
qvtkWidget->GetRenderWindow()->DoubleBufferOff();
// Associate the QVTKWidget with the QGraphicsView
view.setViewport(qvtkWidget);
view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
// Qt vtk integration
ren = vtkRenderer::New();
qvtkWidget->GetRenderWindow()->AddRenderer(ren);
// Geometry
source = vtkCylinderSource::New();
// Mapper
mapper = vtkPolyDataMapper::New();
mapper->ImmediateModeRenderingOn();
mapper->SetInputConnection(source->GetOutputPort());
// Actor in scene
actor = vtkActor::New();
actor->SetMapper(mapper);
// Add Actor to renderer
ren->AddActor(actor);
// Reset camera and render scene
ren->ResetCamera();
ren->GetRenderWindow()->Render();
view.show();
return app.exec();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081017/11cabefa/attachment.htm>
More information about the vtkusers
mailing list