[vtkusers] qvtkWidget as separate window

Jon Agirre jon.agirre at gmail.com
Tue Jan 31 04:18:44 EST 2012


Dear friends,

I'm trying to make an application that should be able to summon a separate
3D graphics window from its main window. As for the UI design, I've chosen
QT 4 in cooperation with VTK. Despite being familiar with the simpleview
qvtkWidget example, I haven't been able to use qvtkwidget in my QT
application, at least not the way I'm used to work with QWidgets. Here go
the options I've tried:

- qvtkWidget alone as separate window -> crash. While I can create a
QWidget object as a separate window, I can't do the same with qvtkwidget.
- qvtkWidget inserted into the layout manager of a separate QWidget, which
is created to be a separate window -> crash. If I do not insert it into the
layout, the QWidget displays just fine.

The code I use for this later option is as follows:

        qvtkWidget = new QVTKWidget();

        window = new QWidget(this, Qt::Window);

        qvtkWidget->resize(640,384);

         vtkSmartPointer<vtkLight> light = vtkSmartPointer<vtkLight>::New();

        light->SetFocalPoint( 0.21406 , 1.5 , 0 );

        light->SetPosition( 8.3761 , 4.94858 , 4.12505 );

 	VTK_CREATE(vtkConeSource, cone);

	cone->SetHeight( 3.0 );

	cone->SetRadius( 1.0 );

        cone->SetResolution( 50 );

 	VTK_CREATE(vtkPolyDataMapper, coneMapper);

        coneMapper->ImmediateModeRenderingOn();

        coneMapper->SetInputConnection( cone->GetOutputPort() );

	 	VTK_CREATE(vtkActor, coneActor);

        coneActor->SetMapper(coneMapper);

         VTK_CREATE(vtkRenderer, renderer);

        renderer->SetBackground(0, 0, 0);

        renderer->AddLight(light);

        renderer->AddActor(coneActor);


        qvtkWidget->GetRenderWindow()->AddRenderer(renderer);


        window->layout()->addWidget(qvtkWidget);


I'm using Mac OS X 10.6, with QT 4 and VTK 5.6.1. The code, as you might
guess, mimics the simpleview example.

Any clues?

Thanks for your time,

Jon

-- 
Dr. Jon Agirre
Postdoctoral Scientist - Protein and
Virus X-ray Crystallography Group
Biophysics Unit (CSIC-UPV/EHU)
+0034946013357
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120131/869cff84/attachment.htm>


More information about the vtkusers mailing list