[vtkusers] Re: Qt4 QMdiArea::addSubWindow() deletes VTK render window

clinton at elemtech.com clinton at elemtech.com
Tue Oct 2 12:59:37 EDT 2007


> When I add a child window derived from QVTKWidget to a QMdiArea,
>     QMdiSubWindow* mdiSubWindow = mdiArea->addSubWindow( mdiChild );
> the VTK render window created in the mdiChild constructor
>
> MdiChild::MdiChild()
> {
>     setAttribute(Qt::WA_DeleteOnClose);

Shouldn't you be setting that delete on close attribute on the QMdiSubWindow 
instead?

>     isUntitled = true;
>
>     // QT/VTK interact
>     ren = vtkRenderer::New();
>     this->GetRenderWindow()->AddRenderer( ren );
> }
>
> is deleted when addSubWindow() returns.

The only way the render window gets deleted is if you call 
SetRenderWindow(NULL) is called or if you delete the QVTKWidget.  In other 
words, the lifetime of the vtkRenderWindow is tied to the lifetime of the 
QVTKWidget, unless you disconnect it, or hold references elsewhere.

> Calling GetRenderWindow() again appears to fix the problem.
> I was wondering if anybody else using QMdiArea has had the same problem
> ( Qt 4.3.1 open source edition, VTK 5.1, VS6, Win XP ).

I just threw together a quick mdi app trying to mirror what you were doing, 
and didn't see any problems.  If your problem still persists, can you send me 
an example?

Clint



More information about the vtkusers mailing list