[vtkusers] qvtkWidget as separate window

Jon Agirre jon.agirre at gmail.com
Tue Jan 31 08:30:15 EST 2012


Hi Doug,

thanks for your reply. I've been able to figure this out myself, according
to Murphy's Law of Support Mailing Lists (Despite having spent two weeks on
one problem, you only get to solve it right after asking for help in the
appropriate mailing list).

The solution seems to be to add the qvtkWidget to a separate QWidget, which
acts as a window. There were two problems: 1) qvtkWidget's parent should be
the widget I'm summoning to act as separate window. 2) In the QWidget's
creator, the flags should be adjusted to something sensible, i.e.
Qt::Dialog. I had them set as Qt::Window.

Thanks!

Jon

2012/1/31 Doug Hoppes <dhoppes at mbfbioscience.com>

> 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****
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>


-- 
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/8ce32944/attachment.htm>


More information about the vtkusers mailing list