Help!! How to use the QRenderCaptureReply class (but in Python)
-
Re: Help!! How to use the QRenderCaptureReply class
I'm having a similar problem, but with a Qt3DWindow in PySide6. I've tried creating the QRenderCapture object with the Qt3DWindow's camera() as its argument, and with the Qt3DWindow.defaultFrameGraph.camera() as well. Seems no matter what I try, the 'completed' signal is never triggered.
self.extrude_window = Qt3DWindow()
self.window_container = createWindowContainer(self.extrude_window)
// Make a PNG file with the contents of the Qt3DWindow
self.renderCapture = Qt3DRender.QRenderCapture(self.extrude_window.camera())
reply = self.renderCapture.requestCapture()
// connect 'completed' signal to _save_png
reply.completed.connect(lambda: self._save_png(file_name, reply))
// but _save_png never gets called
def _save_png(self, file_name: str, reply):
reply.saveImage(file_name)
reply.deleteLater() -
Re: Help!! How to use the QRenderCaptureReply class
I'm having a similar problem, but with a Qt3DWindow in PySide6. I've tried creating the QRenderCapture object with the Qt3DWindow's camera() as its argument, and with the Qt3DWindow.defaultFrameGraph.camera() as well. Seems no matter what I try, the 'completed' signal is never triggered.
self.extrude_window = Qt3DWindow()
self.window_container = createWindowContainer(self.extrude_window)
// Make a PNG file with the contents of the Qt3DWindow
self.renderCapture = Qt3DRender.QRenderCapture(self.extrude_window.camera())
reply = self.renderCapture.requestCapture()
// connect 'completed' signal to _save_png
reply.completed.connect(lambda: self._save_png(file_name, reply))
// but _save_png never gets called
def _save_png(self, file_name: str, reply):
reply.saveImage(file_name)
reply.deleteLater()@DeadComposer said in Help!! How to use the QRenderCaptureReply class (but in Python):
reply = self.renderCapture.requestCapture()What is the scope/lifetime of this
replyvariable? If it is local to a function in Python it will be released when that exits, and may not give enough time forreply.completedsignal to be emitted. -
@DeadComposer said in Help!! How to use the QRenderCaptureReply class (but in Python):
reply = self.renderCapture.requestCapture()What is the scope/lifetime of this
replyvariable? If it is local to a function in Python it will be released when that exits, and may not give enough time forreply.completedsignal to be emitted.@JonB That makes sense, but why does the description of QRenderCaptureReply require that 'reply' be manually deleted with a "deleteLater" call if it will be released automatically when it goes out of scope?
-
@JonB That makes sense, but why does the description of QRenderCaptureReply require that 'reply' be manually deleted with a "deleteLater" call if it will be released automatically when it goes out of scope?
@DeadComposer
The documentation tells you it is your responsibility to delete the reply afterfinishedhas been received, per the code in your slot. The code looks right to me in C++ (where it. Python, however, does its own deletion of objects which (it judges) go out of scope. I believe it will do that on thereplyobject with the code you show at the end of whatever function it is inside.Try making
replybeself.reply, and see if you then hit the slot. -
@DeadComposer
The documentation tells you it is your responsibility to delete the reply afterfinishedhas been received, per the code in your slot. The code looks right to me in C++ (where it. Python, however, does its own deletion of objects which (it judges) go out of scope. I believe it will do that on thereplyobject with the code you show at the end of whatever function it is inside.Try making
replybeself.reply, and see if you then hit the slot.@JonB Tried making it self.reply, and still the 'completed' signal is not triggered.