Qt rendering using OpenGL

2019-04-07 09:27发布

I'm working on a QML application for an embedded platform which includes a GridView widget containing images. It's important for me that scrolling through the GridView will be smooth and will not put load on the CPU. Can I expect Qt to use OpenGL to render the GridView?

标签: qt opengl qml
3条回答
Emotional °昔
2楼-- · 2019-04-07 10:05

By default Qt does not use the OpenGL render backend. You can enforce it by using a QGlWidget. In your case, as you want to use a stock widget, you can set the render backend as a command line option:

<binary name> -graphicssystem opengl
查看更多
做个烂人
3楼-- · 2019-04-07 10:17

I faced with the same problem.

QApplication::setGraphicsSystem(QLatin1String("opengl"));

haven`t work for me. So i set the OGWidget as a viewport:

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);

and do not forget to add opengl in *.pro file.

查看更多
倾城 Initia
4楼-- · 2019-04-07 10:20

Depending on your platform use

QApplication::setGraphicsSystem(QLatin1String("opengl"));

or (Symbian)

QApplication::setGraphicsSystem(QLatin1String("openvg"));

before you instantiate the QApplication object.

查看更多
登录 后发表回答