[vtkusers] Help updating a QVTKWidget

André Prins a.h.prins at gmail.com
Mon Nov 23 08:53:18 EST 2009


You could try calling QVTKWidget::update(), which is Qt's method of
repainting the widget.
See for example: http://doc.trolltech.com/4.5/qwidget.html#update.

Regards,
André

On Mon, Nov 23, 2009 at 2:04 PM, Garrett Larson <garrett at unc.edu> wrote:
> I've created an application that contains a QVTKWidget linked to a
> vtkImageViewer2. Alterations to the vtkImageData before initializing the
> vtkImageViewer2 are visible as soon as I call viewer->Render(), but any
> changes I make later do not appear until I click inside the widget. In fact,
> this happens even if I run the exact same sequence of methods to make a new
> vtkImageViewer2 (as below). Is this a result of the QVTKWidget caching the
> image data, and if so, how can I make it update? Thanks!
>
> ==================
>
>   gridData = vtkImageData::New();
>
> // etc.
>
>   gridData->
> SetScalarTypeToFloat();
>   gridData->AllocateScalars();
>   gridData->GetPointData()->GetScalars()->FillComponent(0,0);
>
>
> // The vtkImageData *gridData is modified via calls to SetScalarComponent...
>
>
> gridData->SetScalarComponentFromDouble((int)pos[0],(int)pos[1],0,0,intensity);
>
>   viewer = vtkImageViewer2::New();
>   viewer->SetInput(gridData);
>   viewer->SetupInteractor(this->ui->qvtkWidget->GetInteractor());
>   viewer->SetRenderWindow(this->ui->qvtkWidget->GetRenderWindow());
>   viewer->Render();
>
> // ... and the modified image is displayed correctly.
>
> // But if the vtkImageData *gridData is further modified via calls to
> SetScalarComponent...
>
>
> gridData->SetScalarComponentFromDouble((int)pos[0],(int)pos[1],0,0,intensity);
>
>   viewer = vtkImageViewer2::New();
>   viewer->SetInput(gridData);
>   viewer->SetupInteractor(this->ui->qvtkWidget->GetInteractor());
>   viewer->SetRenderWindow(this->ui->qvtkWidget->GetRenderWindow());
>   viewer->Render();
>
> // ...the new changes are still not visible until I click the image.
>
> ===================
>
> -Garrett Larson
> _______________________________________________
> 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
>
>



More information about the vtkusers mailing list