How to enable hardware accelerated QML rendering

Update: this is no longer needed with the latest Qt shipping with QtSDK 1.1 TP.

First of all the title is purposefully misleading. I just want to get a good Google pagerank and help people find this page :) The title is misleading, because this is not QtQuick/QML specific, but applies to any drawing done with QPainter.

So all you have to do to supercharge the drawing of your Qt/QtQuick app is call QApplication::setGraphicsSystem() before constructing your QApplication. After doing so all painting done via QPainter will be automagically executed on the GPU.

int main(int argc, char *argv[])
QApplication::setGraphicsSystem("openvg"); // Use "opengl" for systems not supporting OpenVG
QApplication a(argc, argv);
view raw main.cpp hosted with ❤ by GitHub

The latest Symbian hardware (N8, C7, C6-01, X7, E7 and what have you) has OpenVG support. If the device you’re targeting doesn’t support the graphics system you’re asking for Qt will just use the default software rendering.

It’s kind of sad that all this doesn’t somehow “come out of the box”. When a new developer starts with Qt, compiles some examples and tries them out, is it really reasonable to expect him to be aware of all this? First impression is so important and the difference between CPU vs GPU can be this is so lame vs wow, this is so nice! I hope at some point the Symbian port will use OpenVG by default (not sure if this will have some implications though – think 10 apps running at the same time competing for the same limited amount of GPU memory). Meanwhile I guess the only thing to do is to raise awareness. Go tell your friends!

The difference is huuuge when building animated UIs and using the GPU naturally wins hands down. Maybe in some cases when there’s lots of items to paint that require tons of painter state changes (which are poison for efficient use of the GPU) CPU rendering might be faster. Luckily for this problem too there will be a Qt solution which is called Scenegraph. Mark my words: when it gets out, it will be “teh shit” (the good kind) in UI rendering.

If you’re using the Qt 4.7 Symbian^3 developer package note that the OpenVG graphics system has got a few bugs that sometimes cause items to be painted as black rectangles and BorderImage elements have gaps. The bugs have been fixed since, so don’t worry about them.

This entry was posted in Programming and tagged , , , , , , . Bookmark the permalink.

16 Responses to How to enable hardware accelerated QML rendering

  1. Pingback: Mobiele Telefoons » u041au0430u043a u0438u0441u043fu043eu043bu044cu0437u043eu0432u0430u0442u044c GPU u0432 #Qt u043fu0440u0438u043bu043eu0436u0435u043du0438u044fu0445 u0434u043bu044f #Symbian^3 #Nokia #N8 #C7 #QML

  2. Mark Wilcox says:

    This DOES come out of the box with the version that ships in the Symbian^3 device firmware. It’s only when you install the developer version that you need this extra hack. You can easily test this for yourself by seeing how much slower everything is when you do: QApplication::setGraphicsSystem(“raster”);

    Also, when the OpenGL backend is no longer “experimental” that will almost certainly be the fastest option on all platforms supporting it. So then the advice will probably be to use OpenVG on platforms that don’t support OpenGL.

    • elpuri says:

      Well that’s certainly good news. BTW why is raster the default graphics system on the S^3 developer version, if it was good enough to be the default one on the N8 firmware? A blunder in the build?

  3. Pingback: Tweets that mention How to enable hardware accelerated QML rendering | Blogasdf --

  4. A formidable share, I just given this onto a colleague who was doing a bit analysis on this. And he in fact bought me breakfast as a result of I found it for him.. smile. So let me reword that: Thnx for the treat! However yeah Thnkx for spending the time to debate this, I feel strongly about it and love reading extra on this topic. If potential, as you turn out to be experience, would you mind updating your weblog with more details? It is extremely useful for me. Huge thumb up for this blog post!

  5. elpuri says:

    Glad to hear it was useful! This is exactly what I want to accomplish with this blog. If you have any suggestions on what kind of things you would like to read about, I would like to hear them.

  6. ana says:

    i wan’t to write a qml project on a target, and to use the openGL support on the hardware.
    i write in the main program:

    and i got some errors:
    Xlib: extension “GLX” missing on display “:0.0″.
    QGLContext::makeCurrent(): Cannot make invalid context current.

    if someone have an idea….

  7. muenalan says:


    You probably have not activated your graphics drivers “glx” thingy.


    $ gnome-control-center

    in the commandline (or via menu) and look out for the applet named

    Handware/Additional drivers

    At the end, some “green” light should be activated near your graphics driver.

  8. george says:

    I use QApplication::setGraphicsSystem(“raster”) for an application running on ubuntu and it is extremely fast. However, if I use the same application under windows 7 it becomes very slow. Then I tried QApplication::setGraphicsSystem(“opengl”) under windows but some functionality does not work.
    Any ideas?

    • Juha Turunen says:

      Sorry, no ideas why raster would be slow on Windows7. Are you running Ubuntu and W7 on the same hardware? Raster is Qt’s own graphics library which is self-contained so performance shouldn’t depend on the OS.

      What do you mean by some functionality doesn’t work on Windows with opengl graphics system? Are you getting rendering artifacts? Does your Windows’ OpenGL implementation support shaders? I’m not 100% sure, but I think there’s an old OpenGL Qt graphics system that is meant for older fixed pipeline OpenGL implementations and which could be buggy.

  9. stoufa says:

    Thank you very much for this excellent blog ;)
    In Qt SDK 1.2 the hardware accelerated QML rendering is activated by default? I don’t need to activate it manually like in this topic to increase QML performance?

  10. stoufa says:

    Thank you very much for this excellent blog ;)
    In Qt SDK 1.2 the hardware accelerated QML rendering is activated by default? I don’t need to activate it manually like in this topic to increase QML performance? (for Symbian^3 devices like N8 and Nokia 700)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>