[vtkusers] Repainting problem with QVTKWidget
Moreland, Kenneth
kmorel at sandia.gov
Wed Apr 20 11:37:10 EDT 2005
Ruoyun,
I doesn't look like you changed much in paintEvent() except erasing the
window, which is then immediately drawn over. Did the change in
paintEvent() really do anything, or was it turning on the image cache?
Perhaps the problem is that a render within a paintEvent() is not
working for some reason. Qt 4 is a moving target right now, so it's not
very well supported by QVTKWidget. Unless you want to bleed a little,
you may want to consider moving back down to Qt 3.3. That works fine
for me.
-Ken
**** Kenneth Moreland
*** Sandia National Laboratories
***********
*** *** *** email: kmorel at sandia.gov
** *** ** phone: (505) 844-8919
*** fax: (505) 845-0833
> -----Original Message-----
> From: vtkusers-bounces at vtk.org
> [mailto:vtkusers-bounces at vtk.org] On Behalf Of Wu Ruoyun
> Sent: Wednesday, April 20, 2005 3:49 AM
> To: vtkusers at vtk.org
> Subject: RE: [vtkusers] Repainting problem with QVTKWidget
>
> Dear All,
>
> Forget to mention that you also need to call
> setAutomaticImageCacheEnabled( true ); on the QVTKWidget.
>
> Best Wishes!
> Ruoyun
>
> -----Original Message-----
> From: vtkusers-bounces at vtk.org
> [mailto:vtkusers-bounces at vtk.org] On Behalf Of Wu Ruoyun
> Sent: Wednesday, April 20, 2005 5:45 PM
> To: vtkusers at vtk.org
> Subject: RE: [vtkusers] Repainting problem with QVTKWidget
>
> Dear All,
>
> The painting problem mentioned in my previous email could be
> solved by modifying the original paintEvent() method as
> below. Any comments?
>
> Best Wishes!
> Ruoyun
>
> void QVTKWidget::paintEvent(QPaintEvent* event) {
> if (!this->cachedImageCleanFlag)
> {
> vtkRenderWindowInteractor* iren = NULL;
> if(this->mRenWin)
> iren = this->mRenWin->GetInteractor();
>
> if(!iren || !iren->GetEnabled())
> return;
>
> iren->Render();
> }
>
> QPainter painter(this);
> painter.eraseRect( event->rect() );
> painter.drawPixmap(0, 0, this->cachedImage); }
>
> -----Original Message-----
> From: vtkusers-bounces at vtk.org
> [mailto:vtkusers-bounces at vtk.org] On Behalf Of Wu Ruoyun
> Sent: Wednesday, April 20, 2005 4:01 PM
> To: vtkusers at vtk.org
> Subject: [vtkusers] Repainting problem with QVTKWidget
>
> Dear All,
>
> I am working with QVTKWidget with Qt 4.0 Beta2 and VTK CVS
> version, Windows 2K, Visual Studio C++ 6.
>
> The example of QVTKWidget called "ImageViewer" runs well.
> However, I got repainting problem if I put the QVTKWidget as
> the central widget of a QMainWindow. The following is the
> codes. Any mistake in my code or the QVTKWidget still need
> some touch up?
>
> Best Wishes!
> Ruoyun
>
> #include <QApplication.h>
> #include <QMainWindow.h>
> #include <QPushButton>
> #include <QToolBar.h>
> #include <QMenuBar.h>
> #include <QMenu.h>
>
> #include <vtkImageViewer.h>
> #include <vtkRenderWindowInteractor.h>
> #include <vtkPNGReader.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderer.h>
> #include <QVTKWidget.h>
>
> int main( int argc, char* argv[] )
> {
> QApplication app(argc, argv);
> QMainWindow window;
> window.addToolBar( new QToolBar( "Tools", &window ) );
> QMenu* menu = window.menuBar()->addMenu("&File");
> menu->addAction("&Quit", &window, SLOT(close()));
>
> /*
> //**** The normal Qt widget (a button here) repaints fine
> QPushButton hello("Hello world!",&window);
> hello.resize(100, 30);
> window.setCentralWidget( &hello );
> //****
> */
>
> //**** Works if interacting, but not repainted well
> QVTKWidget* widget = new QVTKWidget( &window );
> widget->resize(256,256);
>
> vtkPNGReader* reader = vtkPNGReader::New();
> char* fname =
> "E:/Projects/vtk42/VTKData-release-4-2/Data/vtk.png";
> reader->SetFileName(fname);
>
> vtkImageViewer* image_view = vtkImageViewer::New();
> image_view->SetInput(reader->GetOutput());
>
> widget->SetRenderWindow(image_view->GetRenderWindow());
>
> image_view->SetupInteractor(widget->GetRenderWindow()->GetInte
> ractor());
>
> window.setCentralWidget( widget );
> //****
>
> window.show();
> return app.exec();
> }
>
> -----Original Message-----
> From: vtkusers-bounces at vtk.org
> [mailto:vtkusers-bounces at vtk.org] On Behalf Of Wu Ruoyun
> Sent: Monday, April 18, 2005 5:07 PM
> To: vtkusers at vtk.org
> Subject: [vtkusers] QVTKWidget work with Qt 4.0.0 Beta 2?
>
> Dear All,
>
> Has anyone make QVTKWidget work with Trolltech's newly
> released Qt 4.0.0 Beta 2? I got a number of errors and
> warnings when compiling.
>
> Best Wishes!
> Ruoyun
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the 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