[vtkusers] QPixmap::grabWidget() doesn't work for QVTKWidget

Manuel Feige manuelfeige at googlemail.com
Fri Mar 7 04:35:05 EST 2008


Hi All!
I'm trying to make a screenshot of the QVTKWidget with 
QPixmap::grabWidget(). But this results in a gray picture. I've got the same 
problem in ParaView (3.0.2) when I save a screenshot as pdf file.
I'm using VTK 5.0.3 with QT 4.3.3.
Below you will find a simple test program.

Regards,
Manuel

#include <QtGui>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkPolyDataMapper.h>
#include <vtkSphereSource.h>
#include <QVTKWidget.h>
#include "MainWindow.h"
MainWindow::MainWindow()
{
testAction = new QAction(tr("&Test"), this);
connect(testAction, SIGNAL(triggered()), this, SLOT(test()));
testMenu = menuBar()->addMenu(tr("&Test"));
testMenu->addAction(testAction);
createMainWidget();
showMaximized();
}
void MainWindow::createMainWidget()
{
mainWidget = new QVTKWidget(this);
vtkSphereSource* sphere = vtkSphereSource::New();
vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
mapper->SetInput(sphere->GetOutput());
vtkActor* actor = vtkActor::New();
actor->SetMapper(mapper);
vtkRenderer* ren = vtkRenderer::New();
ren->AddActor(actor);
mainWidget->GetRenderWindow()->AddRenderer(ren);
setCentralWidget(mainWidget);
}
void MainWindow::test()
{
QPixmap pix = QPixmap::grabWidget(mainWidget);
pix.save("C:/Test.bmp");
} 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080307/6e4ff3da/attachment.htm>


More information about the vtkusers mailing list