开发者

Improve performance of "Accelerate your Widgets with OpenGL" Qt Sample?

I have been studying the Qt Quarterly article about QGraphicsScene and OpenGL for the purpose of using it in a project. I have already decided to use Qt, given its all-round excellence, but have gone down the road of implementing a class derived from QGLWidget, however I would then still need to implement the UI elements. Using techniques from the quoted article would mean I could also use Qt widgets for the UI as well, making the program dependent on Qt alone (and not CEGUI or similar).

Anyway I have been running the sample under a desktop Linux machine, which has an Core i7 and a fairly good Nvidia card and it runs well, however my on my 2010 MacBook Pro (Core i5 and Nvidia 330) it runs very poorly indeed, especially when interacting with it using the mouse.

Question: can anyone suggest ways of improving the performance of this sample? I'm no Qt expert but I think the poor response is due to calls to update() from within the mouse handling code coupled with the timed calls to update() at the end of the method itself. I think what is needed is a background thread to update the object movement and 开发者_如何学Goa timed but constant call to update().

Can anyone comment on this?

EDIT: I have already tried removing all calls to update(), apart from the timer reset, and it makes very little difference.


Unfortunately the performance that you get when using the suggestions from that article is pretty bad. We tried that on an embedded system and it was far to slow.

For us the solution was to use QML, the new "declarative" UI capability in Qt 4.7. We have QML embedded in our C++ application. We are seeing huge speed improvements with QML widgets overlaid on top of our GL scene.

We are using the QDeclarativeView widget in our C++ application, which is capable of displaying our QML content. See: http://doc.qt.io/archives/qt-4.7/qdeclarativeview.html.

This should work fine on the desktop (works for me on Ubuntu).

More useful links:

Using QML Bindings in C++ Applications

Integrating QML Code with Existing Qt UI Code

UPDATE! 1/20/2015: In Qt5.4 there is a new class called QOpenGLWidget that basically makes it so you can use "classic" Qt widgets with an OpenGL background with great performance. They finally adressed this issue directly! Read the blog post, and then the docs:

Qt Blog Entry about QOpenGLWidget

QOpenGLWidget Docs

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜