2

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 a 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.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242

1 Answers1

1

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

Christophe Weis
  • 2,518
  • 4
  • 28
  • 32
sidewinderguy
  • 2,394
  • 4
  • 24
  • 24
  • It's great to know there is a way out of this problem! Can you tell a little more about the architecture of your application? Do you use the traditional custom-QGLWidget within a window approach or do you use QGraphicsScene/View? – trojanfoe May 07 '11 at 08:33
  • Is QML supported for Desktop Qt? I cannot get this example to compile: http://talk.maemo.org/showthread.php?t=39913 as I cannot find QmlEngine et al, and there appears to be a research project going on for Desktop Qt-Components: http://qt.gitorious.org/qt-components/desktop. – trojanfoe May 07 '11 at 09:58
  • I added some more detail. Let me know if you need more help! – sidewinderguy May 10 '11 at 22:34