PDA

View Full Version : Capture a Widget with OpenGL content under Qt5.5



adelaune
11th January 2017, 08:48
Hello,

I need to capture a screenshot of a widget with OpenGL content (using SoQt 1.5.0 classes under Qt5.5), and to save it to a QImage. What I've tried so far is:

using grabFrameBuffer from the QGLWidget class (which seems to be obsolete since Qt5): it results in a black area
using grabFramebuffer from the QOpenGLWidget class: the capture doesn't even work and there's no area dedicated to it
using renderPixmap from the QGLWidget class: it results in a white area


The problem seems to be located in this if condition (which used QGLWidget::grabFrameBuffer() under Qt4.8 and which we are trying to migrate to Qt5.5):


if(dynamic_cast<QGLWidget*>(rendererCourant->getNormalWidget()))
{
((QGLWidget*)rendererCourant->getNormalWidget())->updateGL();
_image = ((QGLWidget*)(rendererCourant->getNormalWidget()))->grabFrameBuffer();
}


Does someone have a hint on the matter ?

Best regards,

Anthony