diff options
Diffstat (limited to 'tests/manual/rendercapture-cpp/mycapture.h')
-rw-r--r-- | tests/manual/rendercapture-cpp/mycapture.h | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/tests/manual/rendercapture-cpp/mycapture.h b/tests/manual/rendercapture-cpp/mycapture.h index 803ef7336..fea1abe46 100644 --- a/tests/manual/rendercapture-cpp/mycapture.h +++ b/tests/manual/rendercapture-cpp/mycapture.h @@ -60,31 +60,26 @@ class MyCapture : public QObject public: MyCapture(Qt3DRender::QRenderCapture* capture, QLabel *imageLabel) : m_capture(capture) - , m_cid(1) - , m_imageLabel(imageLabel) , m_reply(nullptr) + , m_imageLabel(imageLabel) , m_continuous(false) { } public slots: - void onCompleted(bool isComplete) + void onCompleted() { - if (isComplete) { - QObject::disconnect(connection); - - m_imageLabel->setPixmap(QPixmap::fromImage(m_reply->image())); + QObject::disconnect(connection); - ++m_cid; + m_imageLabel->setPixmap(QPixmap::fromImage(m_reply->image())); - m_reply->saveToFile("capture.bmp"); + m_reply->saveImage("capture.bmp"); - delete m_reply; - m_reply = nullptr; + delete m_reply; + m_reply = nullptr; - if (m_continuous) - capture(); - } + if (m_continuous) + capture(); } void setContinuous(bool continuos) @@ -94,9 +89,11 @@ public slots: void capture() { - m_reply = m_capture->requestCapture(m_cid); - connection = QObject::connect(m_reply, &Qt3DRender::QRenderCaptureReply::completeChanged, - this, &MyCapture::onCompleted); + if (!m_reply) { + m_reply = m_capture->requestCapture(); + connection = QObject::connect(m_reply, &Qt3DRender::QRenderCaptureReply::completed, + this, &MyCapture::onCompleted); + } } private: @@ -105,7 +102,6 @@ private: QMetaObject::Connection connection; QLabel *m_imageLabel; bool m_continuous; - int m_cid; }; #endif |