Skip to content

Writing custom Qt Quick components using OpenGL Kevin Funk

Qt Quick and QML provide an easy way to rapidly develop customized, reusable components entirely within QML. As these components grow in complexity, performance and maintainability often suffer, a drawback that is especially noticeable on low-powered embedded and mobile devices. In addition, some specialized components simply cannot be implemented by combining existing Qt Quick items in QML. For these cases, Qt Quick provides access to its underlying OpenGL scene graph via a C++ API. Components created this way are more closely aligned to the underlying scene graph architecture allowing improved performance and a cleaner implementation.

Qt Quick provides a flexible and easy-to-use framework for developing a wide range of applications from automotive HMIs to interactive desktop applications. Under the hood, it uses an OpenGL scene graph for rendering, allowing advanced effects and fluid animations even on low-powered systems. Complex components written entirely in QML can cause noticeable performance problems especially on these low-powered systems. Qt Quick provides a C++ API to directly access its underlying scene graph for creating optimized components with better encapsulation. These components can then be reused from QML in the same way as the built-in Qt Quick items.

The focus of this talk will be describing the steps necessary to create a Qt Quick component using C++ and OpenGL. We will start with a custom component written entirely in QML and point out the performance and maintenance problems with this approach. We will then reimplement this component in C++ and OpenGL, step-by-step, so that by the end you’ll know enough to create your own C++ Qt Quick components. Finally we’ll compare the resulting component’s implementation and performance against the original to see the improvement. I will also briefly mention the QtQuickFrameBufferObject as an alternative and discuss when you would use it instead of the scene graph API.

The talk is aimed at developers with minimal OpenGL experience. It will briefly introduce enough of the basic OpenGL concepts to get you started writing a custom Qt Quick item.

View the slides

Categories: OpenGL / Presentation videos / QML

Leave a Reply

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