Solved. I managed to get it working. Trick was to link the FrameGraph to the QRenderCapture instance. Here is the code added to init()
self.render_capture = QRenderCapture()
self.view.activeFrameGraph().setParent(self.render_capture)
self.view.setActiveFrameGraph(self.render_capture)
The other gotcha is to wait for the rendering to complete. Here is how I implemented it.
def capture_image(self):
self.reply = self.render_capture.requestCapture()
loop = QEventLoop()
self.reply.completed.connect(loop.quit)
QTimer.singleShot(200, loop.quit) # Timeout after 1 second
loop.exec()
image = self.reply.image()
image.save("capture_output.jpg", "JPG")
I just can't believe how poorly documented this Qt3D library is...