[Development] Qt 5.2.1 save QWindow (Qt3D) as image/screenshot

Miroslav Karpis miroslav.karpis at gmail.com
Mon Apr 7 14:18:08 CEST 2014


Hi,
I'm new to this list, so please re-direct me if I'm not at the right place.


I'm having problems with saving a qt3d window to image. #1, #2, #3 gives me
blank image. #3 not the right screenshot. When I show() plot3D or plotWidget
everything looks good (I get the correct drawing/plot).


Any comments/ideas more than appreciated ;-)


Cheers,
Miro


Here are my 4 approaches:
QGLView *plot3D = dynamic_cast<QGLView *>(mItemPtr.data());

plot3D->show();

//#1
QWidget *plotWidget = QWidget::createWindowContainer(plot3D);
plotWidget->show();
const QRect rect = plotWidget->grab().rect();
QPixmap pix1 = QPixmap::grabWidget(plotWidget);
pix1.save("img1.png");

//#2
QPixmap pix2 = plotWidget->grab();
pix2.save("img2.png");

//#3
QImage bitmap(rect.size(), QImage::Format_ARGB32);
QPainter painter(&bitmap);
plotWidget->render(&painter, QPoint(), QRegion(), QWidget::DrawChildren);
bitmap.save("img3.png");

//#4
QPixmap::grabWindow(plot3D->winId()).save("img4.png");


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140407/1da44b97/attachment.html>


More information about the Development mailing list