I need to capture every QML drawing frame (QtQuick 2) and send it over the network. At the moment, I used the method below, but this method has two big drawbacks
1) Due to the Qt5 documentation, the grabWindow () function has performance issues
2) It cannot work with a hidden QML window
Is it possible to get the OpenGL rendering buffer right after QQuickWindow :: afterRendering? Using TSF? General opengl context?
class Grab: public QObject { public: Grab( QQuickWindow * wnd ) : wnd_(wnd) {} public slots: void Grabme() { QImage image = wnd_->grabWindow(); } private: QQuickWindow *wnd_; }; int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QtQuick2ApplicationViewer viewer; viewer.setMainQmlFile(QStringLiteral("qml/grab1/main.qml")); viewer.showExpanded(); Grab grab( &viewer ); QObject::connect( &viewer, &QtQuick2ApplicationViewer::frameSwapped, &grab, &Grab::Grabme, Qt::DirectConnection ); return app.exec(); }
source share