使用OpenGL进行Qt渲染

wan*_*ear 7 opengl qt qml

我正在为嵌入式平台开发一个QML应用程序,其中包含一个包含图像的GridView小部件.对我来说重要的是滚动GridView将是平滑的并且不会在CPU上加载.我可以期待Qt使用OpenGL来渲染GridView吗?

avi*_*ida 5

我遇到了同样的问题.

QApplication::setGraphicsSystem(QLatin1String("opengl"));
Run Code Online (Sandbox Code Playgroud)

对我不起作用.所以我将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);
Run Code Online (Sandbox Code Playgroud)

并且不要忘记在*.pro文件中添加opengl.