【发布时间】:2013-06-13 08:40:18
【问题描述】:
我需要获取每个 QML (QtQuick 2) 绘图框架并通过网络发送。 目前我使用了下面列出的方法,但是这种方法有两个很大的缺点
1) 由于 Qt5 文档中的 grabWindow() 函数存在性能问题
2) 它不能与隐藏的 QML 窗口一起使用
是否可以在 QQuickWindow::afterRendering 之后立即获得 OpenGL 渲染缓冲区? 使用 FBO 吗?共享 opengl 上下文?
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();
}
【问题讨论】:
标签: qt opengl qml qt5 screen-capture