[vtkusers] Rendering QVTKWidget into QPixmap

Christian Lackas lackas at invicro.com
Wed Feb 8 07:16:33 EST 2012


Hi Everybody,

we are using VTK in a Qt-based application of ours and employ QVTKWidget
for this. To allow the user to store rendered data as images, we use
code such as:

    class VRenderer: public QVTKWidget {
        Q_OBJECT
        public:
            ...
            QPixmap grabImage() {
                QPixmap pixmap( size() );
                render( &pixmap );
                return pixmap;
            }
        ...
    };

and then use the QPixmap object to produce an image file (which aligns
well with our non-VTK-based rendering widgets).
On Mac OS X, as well as Linux and many Windows systems this does work
pretty well. Unfortunately, we do have a couple of Windows system
(Vista, 7, 32- and 64-bit, but not consistently on one platform) where
above code produces merely an all-black image.
I assume this has something to do with how the graphic card driver
handles the OpenGL drawing (or something along this line, e.g.
asynchronous processing, where we grab the image to early, etc...).

I already tried using functions such as vtkRenderWindow::WaitForCompletion(),
however, as the documentation suggest that was not useful here, calling
vtkRenderWindow::Render() explicitly myself, etc...

Is there a way to make sure that a QVTKWidget renders and actual image
into my pixmap?

Or should I start using vtkRenderWindow::GetRGBAPixelData() instead?

Thanks for any hints.
 Christian

-- 
http://www.invicro.com/  http://www.spect-ct.com/



More information about the vtkusers mailing list