我正在为嵌入式平台开发一款QML应用程序,其中包括一个包含图像的GridView小部件。对于我来说,重要的是滚动GridView时顺畅,并且不会给CPU带来负载。我可以期待Qt使用OpenGL来渲染GridView吗?
我遇到了同样的问题。
QApplication::setGraphicsSystem(QLatin1String("opengl"));
这个方法对我没有用。所以我将OGWidget设置为视口:
QDeclarativeView mainwindow;
mainwindow.setSource(QUrl::fromLocalFile("./qml/app.qml"));
QGLFormat format = QGLFormat(QGL::DirectRendering); // you can play with other rendering formats like DoubleBuffer or SimpleBuffer
format.setSampleBuffers(false);
QGLWidget *glWidget = new QGLWidget(format);
glWidget->setAutoFillBackground(false);
mainwindow.setViewport(glWidget);
根据您使用的平台
QApplication::setGraphicsSystem(QLatin1String("opengl"));
QApplication::setGraphicsSystem(QLatin1String("openvg"));
默认情况下,Qt不使用OpenGL渲染后端。您可以通过使用QGlWidget来强制使用它。在您的情况下,由于您想要使用一个现成的小部件,您可以将渲染后端设置为命令行选项:
<binary name> -graphicssystem opengl