PDA

View Full Version : QSurface to image



kkingstoun
20th February 2017, 19:39
Hello,

how to export image or take a snapshot of QSurface Widget?

I'm using QSurface example.

Kking


Edit: i have found a solution:


QPixmap::grabWindow(graph->winId()).save("img.png");

d_stranz
21st February 2017, 15:58
QPixmap::grabWindow() is an obsolete method which should not be used in new code. It could be removed in a future Qt release.

If your surface is an OpenGL window, then you can use QOpenGLWindow::grabFrameBuffer() to get a QImage. If it is a QML scene window, use QQuickWindow::grabWindow(). If it is a widget, use QWidget::grab() or QWidget::render().