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):
Qt Code:
  1. if(dynamic_cast<QGLWidget*>(rendererCourant->getNormalWidget()))
  2. {
  3. ((QGLWidget*)rendererCourant->getNormalWidget())->updateGL();
  4. _image = ((QGLWidget*)(rendererCourant->getNormalWidget()))->grabFrameBuffer();
  5. }
To copy to clipboard, switch view to plain text mode 

Does someone have a hint on the matter ?

Best regards,

Anthony