[vtkusers] qvtkWidget as separate window

Doug Hoppes dhoppes at mbfbioscience.com
Tue Jan 31 08:13:03 EST 2012


Hi Jon,

                I don't have time right now, but I can take a look at this later.

                A couple of questions:

1)      Can you set the vtk widget to the main windows central widget?

2)      For the other window, are you using a docking window (QDockWidget) or QDialog?

Dougie


From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of Jon Agirre
Sent: Tuesday, January 31, 2012 4:19 AM
To: vtkusers at vtk.org
Subject: [vtkusers] qvtkWidget as separate window

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/2c5b045c/attachment.htm>


More information about the vtkusers mailing list