Trusted Software Excellence across Desktop and Embedded
Take a glance at the areas of expertise where KDAB excels ranging from swift troubleshooting, ongoing consulting and training to multi-year, large-scale software development projects.
Find out why customers from innovative industries rely on our extensive expertise, including Medical, Biotech, Science, Renewable Energy, Transportation, Mobility, Aviation, Automation, Electronics, Agriculture and Defense.
High-quality Embedded Engineering across the Stack
To successfully develop an embedded device that meets your expectations regarding quality, budget and time to market, all parts of the project need to fit perfectly together.
Learn more about KDAB's expertise in embedded software development.
Where the capabilities of modern mobile devices or web browsers fall short, KDAB engineers help you expertly architect and build high-functioning desktop and workstation applications.
Extensible, Safety-compliant Software for the Medical Sector
Create intelligent, patient-focused medical software and devices and stay ahead with technology that adapts to your needs.
KDAB offers you expertise in developing a broad spectrum of clinical and home-healthcare devices, including but not limited to, internal imaging systems, robotic surgery devices, ventilators and non-invasive monitoring systems.
Building digital dashboards and cockpits with fluid animations and gesture-controlled touchscreens is a big challenge.
In over two decades of developing intricate UI solutions for cars, trucks, tractors, scooters, ships, airplanes and more, the KDAB team has gained market leading expertise in this realm.
Build on Advanced Expertise when creating Modern UIs
KDAB assists you in the creation of user-friendly interfaces designed specifically for industrial process control, manufacturing, and fabrication.
Our specialties encompass the custom design and development of HMIs, enabling product accessibility from embedded systems, remote desktops, and mobile devices on the move.
Legacy software is a growing but often ignored problem across all industries. KDAB helps you elevate your aging code base to meet the dynamic needs of the future.
Whether you want to migrate from an old to a modern GUI toolkit, update to a more recent version, or modernize your code base, you can rely on over 25 years of modernization experience.
KDAB offers a wide range of services to address your software needs including consulting, development, workshops and training tailored to your requirements.
Our expertise spans cross-platform desktop, embedded and 3D application development, using the proven technologies for the job.
When working with KDAB, the first-ever Qt consultancy, you benefit from a deep understanding of Qt internals, that allows us to provide effective solutions, irrespective of the depth or scale of your Qt project.
Qt Services include developing applications, building runtimes, mixing native and web technologies, solving performance issues, and porting problems.
KDAB helps create commercial, scientific or industrial desktop applications from scratch, or update its code or framework to benefit from modern features.
Discover clean, efficient solutions that precisely meet your requirements.
Boost your team's programming skills with in-depth, constantly updated, hands-on training courses delivered by active software engineers who love to teach and share their knowledge.
Our courses cover Modern C++, Qt/QML, Rust, 3D programming, Debugging, Profiling and more.
The collective expertise of KDAB's engineering team is at your disposal to help you choose the software stack for your project or master domain-specific challenges.
Our particular focus is on software technologies you use for cross-platform applications or for embedded devices.
Since 1999, KDAB has been the largest independent Qt consultancy worldwide and today is a Qt Platinum partner. Our experts can help you with any aspect of software development with Qt and QML.
KDAB specializes in Modern C++ development, with a focus on desktop applications, GUI, embedded software, and operating systems.
Our experts are industry-recognized contributors and trainers, leveraging C++'s power and relevance across these domains to deliver high-quality software solutions.
KDAB can guide you incorporating Rust into your project, from as overlapping element to your existing C++ codebase to a complete replacement of your legacy code.
Unique Expertise for Desktop and Embedded Platforms
Whether you are using Linux, Windows, MacOS, Android, iOS or real-time OS, KDAB helps you create performance optimized applications on your preferred platform.
If you are planning to create projects with Slint, a lightweight alternative to standard GUI frameworks especially on low-end hardware, you can rely on the expertise of KDAB being one of the earliest adopters and official service partner of Slint.
KDAB has deep expertise in embedded systems, which coupled with Flutter proficiency, allows us to provide comprehensive support throughout the software development lifecycle.
Our engineers are constantly contributing to the Flutter ecosystem, for example by developing flutter-pi, one of the most used embedders.
KDAB invests significant time in exploring new software technologies to maintain its position as software authority. Benefit from this research and incorporate it eventually into your own project.
Start here to browse information on the KDAB website(s) and take advantage of useful developer resources like blogs, publications and videos about Qt, C++, Rust, 3D technologies like OpenGL and Vulkan, the KDAB developer tools and more.
The KDAB Youtube channel has become a go-to source for developers looking for high-quality tutorial and information material around software development with Qt/QML, C++, Rust and other technologies.
Click to navigate the all KDAB videos directly on this website.
In over 25 years KDAB has served hundreds of customers from various industries, many of them having become long-term customers who value our unique expertise and dedication.
Learn more about KDAB as a company, understand why we are considered a trusted partner by many and explore project examples in which we have proven to be the right supplier.
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications.
Read more about the history, the values, the team and the founder of the company.
When working with KDAB you can expect quality software and the desired business outcomes thanks to decades of experience gathered in hundreds of projects of different sizes in various industries.
Have a look at selected examples where KDAB has helped customers to succeed with their projects.
KDAB is committed to developing high-quality and high-performance software, and helping other developers deliver to the same high standards.
We create software with pride to improve your engineering and your business, making your products more resilient and maintainable with better performance.
KDAB has been the first certified Qt consulting and software development company in the world, and continues to deliver quality processes that meet or exceed the highest expectations.
In KDAB we value practical software development experience and skills higher than academic degrees. We strive to ensure equal treatment of all our employees regardless of age, ethnicity, gender, sexual orientation, nationality.
Interested? Read more about working at KDAB and how to apply for a job in software engineering or business administration.
In this series of blog posts, we'll look under the hood of the QML engine and uncover some of its inner workings. The articles are based on the Qt5 version of QtQuick, QtQuick 2.0.
Most people know that each element in a QML file is backed by a C++ class. When a QML file is loaded, the QML engine somehow creates one C++ object for all elements in the file. In this blog post, we'll examine how the QML engine goes from reading a text file to having a complete tree of C++ objects. The Qt documentation on QML has extensive descriptions that cover how QML and C++ work together, a read that is well worth the time. In the blog series, I am assuming the parts covered by that documentation are understood.
The Example
Throughout this post, we'll use an example that doesn't do any useful or exciting, but covers some interesting parts of the QML functionality:
This file has three elements in it, Rectangle, Text and MouseArea. These correspond to the C++ classes QQuickRectangle, QQuickText and QQuickMouseArea. Those classes are only exported to QML, the C++ versions are private and not available for users of Qt. The elements are drawn using a OpenGL scenegraph. Drawing and event handling are both orchestrated by QQuickView . The C++ object tree corresponds to the one in the QML file, which we can verify with KDAB's Qt introspection tool, Gammaray:
As expected, the classes QQuickMouseArea and QQuickText show up in the object tree. But what is QQuickRectangle_QML_0? There is no C++ class with such a name in the Qt sources! We'll come back to that in a later blog post, for now you can assume that an object of type QQuickRectangle was used.
Let's go a step further and run the application in the QML profiler:
We see that a bunch of time is spent setting up the scene, which is the Creating phase. This is followed by a bit of Painting, which is what we would expect. But what is this Compiling phase? Is it creating machine code? Time to dig into the QML file loading code a bit deeper.
QML File Loading Steps
When loading a QML file, there are 3 distinct steps happening, which we'll examine in the following sections:
Parsing
Compiling
Creating
Parsing
First of all, the QML file is parsed, which is handled by QQmlScript::Parser (Doesn't exist anymore). Most of the parser internals are auto-generated from a grammar file. The abstract syntax tree (AST) of our example looks like this:
This was generated by graphviz using a dotfile produced with the patch at http://www.kdab.com/~thomas/stuff/ast-graph.diff
The AST is quite low-level, therefore it is transformed into a higher level structure of Objects, Properties and Valuesin the next step. This is done using a visitor on the AST. At this level, Objects correspond to QML elements, and Property/Value pairs to QML properties and values like "color" and "lightsteelblue". Even signal handlers like onClicked are just property/value pairs, in this case the value is the Javascript function body.
Compiling
Now in theory, the structure of Objects, Properties and Values would be enough to examine for creating the associated C++ objects and assigning the values to the properties there. However, the Objects, Properties and Values are still quite raw, and require some post-processing before the C++ objects can be created. This post-processing is done by QQmlCompiler, which explains what the compiling phase we saw in the QML profiler is about. The compiler creates an QQmlCompiledData object for the QML file. Examining QQmlCompiledData and creating C++ objects from it is quite a lot faster than examining the Objects, Properties and Values. When using a QML file multiple times, say for example a Button.qml that is used all over the place in other QML files, Button.qml would only be compiled once. The QQmlCompiledData for Button.qml is kept around, and each time a Button component is used, the C++ objects are created by examining the QQmlCompiledData. The later is the creating phase, which can be seen in the QML profiler output.
To sum up: Parsing a QML file and compiling it is only done once, after that the QQmlCompiledData object is used to quickly create the C++ objects.
Creating
I won't go into details about QQmlCompiledData, but one thing might have caught your attention: The "QByteArray bytecode" member variable. The instructions to create C++ objects and to assign the correct values to its properties are actually compiled to bytecode, which is then later interpreted by a bytecode interpreter! The bytecode contains a bunch of instructions, and the rest of QQmlCompiledData is just used as auxiliary data when executing the instructions.
In the creating phase, the bytecode is interpreted by the class QQmlVME. Looking into QQmlVME::run(), the interpreter basically loops over all instructions contained in the bytecode, with a big switch statement for the different instruction types. By running the app with QML_COMPILER_DUMP=1, we can see the individual instructions of the bytecode:
CREATE_SIMPLE is the most important instruction, it creates a C++ object, using a database of registered objects in QQmlMetaType. STORE_INTEGER is the instruction to write an integer value to a property. STORE_SIGNAL is used to create a bound signal handler. STORE_*_BINDING is used to create a property binding. More about bindings to come in the next blog post of this series. SETID obviously sets the identifier of an object, which is not an ordinary property.
The VME has a stack of objects, all instructions like STORE_* operate on the top object. FETCH puts a specific QObject on top of the stack, POP removes the top object. All of the instructions make heavy use of integer indices, for example the STORE_COLOR instruction writes to property 41, which is the property index of the target QObject's meta object.
To sum up: Once a QML file is compiled, creating an instance of it is just a matter of executing the bytecode of the compiled data.
Conclusion
That is the end of this blog post, we have covered on how a QML file is parsed, processed, compiled and later how the objects are actually created by the VME. I hope you gained some interesting insights about the QML engine.
Stay tuned for the next blog post, in which we'll examine how property bindings work.
Really interesting post! I didn't know the internals of QML, and they seem quite well thought. For me it's been a surprise that there's actually a step that compiles to bytecode. Keep the posts coming =)
27 - Jul - 2012
Laszlo Papp
Very useful post. Thank you. :-)
It always bugged me a bit I do not know much about the underlyings.
28 - Jul - 2012
Timur Kristóf
Very nice article, it explains a lot of unanswered questions for me. :)
11 - Aug - 2012
charley
Good info, nice details, well-written. Keep these coming! High value here!
13 - Sept - 2012
Laszlo Papp
I have two minor questions:
1) What does the "VME" abbreviate in the class name "QQmlVME"?
2) Can you describe in few words (perhaps give an example) what the visitor does during the low to high-level transformation?
13 - Sept - 2012
Thomas McGuire
1) I don't know actually... I suspect something like Virtual Machine Environment
2) The visitor basically iterates over all nodes in the AST and creates QQmlScript::Objects, Properties and Values for the nodes. The tree of Objects, Properties and Values is the high level structure.
For example when the an UiObjectDefinition node is encountered, the visitor creates an Object for that, then processes all child AST nodes of the object. These child AST nodes might for example be property definitions, which would then be added as a Property to the parent Object.
I suggest to step over the code in a debugger to see how it works in detail.
13 - Sept - 2012
Raul Guerrero
Hi,
Does anyone know anything about precompiling QML into bytecode so to protect your QML code to be read or decompiled from a QRC file?
Check
13 - Sept - 2012
Thomas McGuire
QML has no support for precompiling. It sure would be nice, would remove the 'compiling' phase from startup.
There was some talk about this feature, can't remember where I read about that. The conclusion was that while it is technically a good idea and apparently not too hard to implement, just no one had time to add this feature yet.
28 - Sept - 2012
Kacper Gazda
Pretty interesting and a nice article.
4 - Nov - 2014
dyamsu
Hi
The QML internals described neatly, which are not found at one place at Qt website.
I notice that, there are many links in the article still pointing to QtDeclarative/..
It would be nice to see if those broken links are fixed, just in case, if the internal things have already got changed(evolved), it would address that also.
As for fixing the links: The content as a whole is quite outdated by now, as the QML engine evolved quickly. For example, the QML engine doesn't have a VME anymore. Thus, the article needs a large rewrite,, or maybe a followup article. I don't have plans for any of that at the moment though.
29 - Jan - 2015
Li Qaul
@Thomas McGuire
Hi, this post is very helpful to me.
now we will use Qt QML for our APP(IOS), but we want to use iOS
base widgets like UIView, UILabel, UIButton, so we just want to replace QQuickText to UILabel in object creating, i want to know if this is possible and how ? thanks very much.
29 - Jan - 2015
Thomas McGuire
QML with another UI than QtQuick has been done before, for example Blackberry's Cascades UI framework.
So using native iOS controls with QML is in theory possible, however I am not aware of an existing project providing a QML API for iOS controls, so you'd have to write that API yourself. Recently, someone did exactly that for native Android controls, wrapping them in a QML API: https://development.qt-project.narkive.com/0qSpC2Uv/qml-bindings-for-native-android-controls So you could do the same for iOS and write a QML API. If you do so, please publish that project, I am sure others would find it useful too.
13 Comments
27 - Jul - 2012
Eduardo Robles Elvir
Really interesting post! I didn't know the internals of QML, and they seem quite well thought. For me it's been a surprise that there's actually a step that compiles to bytecode. Keep the posts coming =)
27 - Jul - 2012
Laszlo Papp
Very useful post. Thank you. :-)
It always bugged me a bit I do not know much about the underlyings.
28 - Jul - 2012
Timur Kristóf
Very nice article, it explains a lot of unanswered questions for me. :)
11 - Aug - 2012
charley
Good info, nice details, well-written. Keep these coming! High value here!
13 - Sept - 2012
Laszlo Papp
I have two minor questions:
1) What does the "VME" abbreviate in the class name "QQmlVME"? 2) Can you describe in few words (perhaps give an example) what the visitor does during the low to high-level transformation?
13 - Sept - 2012
Thomas McGuire
1) I don't know actually... I suspect something like Virtual Machine Environment
2) The visitor basically iterates over all nodes in the AST and creates QQmlScript::Objects, Properties and Values for the nodes. The tree of Objects, Properties and Values is the high level structure. For example when the an UiObjectDefinition node is encountered, the visitor creates an Object for that, then processes all child AST nodes of the object. These child AST nodes might for example be property definitions, which would then be added as a Property to the parent Object. I suggest to step over the code in a debugger to see how it works in detail.
13 - Sept - 2012
Raul Guerrero
Hi,
Does anyone know anything about precompiling QML into bytecode so to protect your QML code to be read or decompiled from a QRC file? Check
13 - Sept - 2012
Thomas McGuire
QML has no support for precompiling. It sure would be nice, would remove the 'compiling' phase from startup.
There was some talk about this feature, can't remember where I read about that. The conclusion was that while it is technically a good idea and apparently not too hard to implement, just no one had time to add this feature yet.
28 - Sept - 2012
Kacper Gazda
Pretty interesting and a nice article.
4 - Nov - 2014
dyamsu
Hi The QML internals described neatly, which are not found at one place at Qt website.
I notice that, there are many links in the article still pointing to QtDeclarative/.. It would be nice to see if those broken links are fixed, just in case, if the internal things have already got changed(evolved), it would address that also.
Thanks
5 - Nov - 2014
Thomas McGuire
Right, there are a lot of outdated links on this page. I recommend browsing the code at http://code.woboq.org/qt5/qtdeclarative/.
As for fixing the links: The content as a whole is quite outdated by now, as the QML engine evolved quickly. For example, the QML engine doesn't have a VME anymore. Thus, the article needs a large rewrite,, or maybe a followup article. I don't have plans for any of that at the moment though.
29 - Jan - 2015
Li Qaul
@Thomas McGuire Hi, this post is very helpful to me. now we will use Qt QML for our APP(IOS), but we want to use iOS base widgets like UIView, UILabel, UIButton, so we just want to replace QQuickText to UILabel in object creating, i want to know if this is possible and how ? thanks very much.
29 - Jan - 2015
Thomas McGuire
QML with another UI than QtQuick has been done before, for example Blackberry's Cascades UI framework.
So using native iOS controls with QML is in theory possible, however I am not aware of an existing project providing a QML API for iOS controls, so you'd have to write that API yourself. Recently, someone did exactly that for native Android controls, wrapping them in a QML API: https://development.qt-project.narkive.com/0qSpC2Uv/qml-bindings-for-native-android-controls So you could do the same for iOS and write a QML API. If you do so, please publish that project, I am sure others would find it useful too.