Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Getting a snapshot of a QDeclarativeItem/QGraphicsVideoItem (OpenGL?)
GordonSchumacher last edited by
I have a QML application which uses a QDeclarativeItem, pulled in from a C++ plugin. This item has a QGraphicsVideoItem as a child, filling its entirety. I would like to capture a QPixmap or QImage of the contents of either of these items (since they should be identical as displayed on the screen). I've tried many variations of the following code:
QSize useSize = scene()->size().toSize();
QSize useSize = boundingRect().size().toSize();
QImage image(useSize, QImage::Format_RGB32);
paint(&painter, 0, 0); // I have tried passing in a QStyleOptionGraphicsItem with exposedRect set to boundingRect()
With paint(), I am left with either an all-green or all-black image; with scene()->render(), the other items in the scene are rendered correctly, but the QGraphicsVideoItem is blank.
This is on MeeGo, which I believe always uses "-graphicssystem opengl" - at the very least, if I start a test app without those switches then the QGraphicsVideoItem is not displayed.
I suspect that my problem has something to do with the OpenGL backend, but I'm at a loss. Does anyone have any ideas here? TIA...
giesbert last edited by
Did you try to use "QPixmap::grabWindow":http://doc.qt.nokia.com/latest/qpixmap.html#grabWindow ?