使用 OpenGL 进行 Qt 渲染

发布于 2024-11-17 11:43:53 字数 129 浏览 4 评论 0原文

我正在为嵌入式平台开发 QML 应用程序,其中包括一个包含图像的 GridView 小部件。对我来说重要的是,在 GridView 中滚动会很流畅并且不会给 CPU 带来负载。我可以期望 Qt 使用 OpenGL 来渲染 GridView 吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

乱世争霸 2024-11-24 11:43:53

我面临着同样的问题。

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

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

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.

泪意 2024-11-24 11:43:53

根据

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

使用的平台或(Symbian) 。

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

您实例化 QApplication 对象之前

Depending on your platform use

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

or (Symbian)

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

before you instantiate the QApplication object.

青芜 2024-11-24 11:43:53

默认情况下,Qt 不使用 OpenGL 渲染后端。您可以使用 QGlWidget 强制执行它。在您的情况下,当您想使用库存小部件时,您可以将渲染后端设置为命令行选项:

<binary name> -graphicssystem opengl

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文