Create a pixmap from a QQuickItem (in Qt5)
-
I wanted to create a pixmap from a QQuickItem (or a QML item and all it's children). What I want is like to take a screenshot of this Item, and store it in a QPixmap / QImage.
With Qt4, it was easy to paint the item into a QPixmap, but with the new Scenegraph, I don't know how to proceed, so is this possible and how can we do this ?
-
You can use the "QImage QQuickCanvas::grabFrameBuffer();" method to grab the whole visible canvas region and copy out the item rect.
Here is an example shows how you can grab an item as QImage:
http://qt.gitorious.org/qt/qtdeclarative/blobs/master/src/qmltest/quicktestresult.cpp#line589
-
Nice, thanks, I will definitely check that