Unsolved Help!! How to use the QRenderCaptureReply class
-
Due to the need of the project, I want to take screenshots of 3Dwindow, but this is the first time for me to use class QRenderCaptureReply , and there is no similar example provided by the official, I would like to ask how to use QRenderCaptureReply, do you have any reference demo? Thrans~~
-
Qt3DRender::QRenderCapture* capture = new Qt3DRender::QRenderCapture(myCamera); // myCamera is of type Qt3DRender::QCamera* Qt3DRender::QRenderCaptureReply* reply = capture->requestCapture(); QObject::connect(reply, &Qt3DRender::QRenderCaptureReply::completed, [&]() { reply->image().save("capture.png"); reply->deleteLater(); });
untested though, but this should do
-
Very thank you for your reply, I found that calls your procedure, the returned is an empty image, debugging and found no trigger Qt3DRender: : QRenderCaptureReply: : completed signals, I wonder if call time is too short and not enough rendering? In addition, I would like to ask that I found the demo written by others on the Internet, as follows:
auto camSelector = this->defaultFrameGraph()->findChildQt3DRender::QCamera*();
m_cap = new Qt3DRender::QRenderCapture(camSelector);
connect(this, &Q3DShowWindow::signalGetImage,&{
QEventLoop loop;
auto reply = m_cap->requestCapture();
qDebug()<<"wait for m_returnimage finish";
connect(reply, &Qt3DRender::QRenderCaptureReply::completed, [&] {
m_returnImage = reply->image();
reply->deleteLater();
loop.quit();
});
loop.exec();
});
I found that when the signalGetImage signal is triggered, the program has been debugging information qDebug () has been unable to enter, do you know why? And how do you change the program? Looking forward to your reply!! -