Qt Quick vs Qt Widgets
How to choose between Qt Quick and Qt Widgets? The latter has been replaced by Qt Quick but retains one small advantage!
23/02/2023
Nathanaël Landais
Your choice is made—you're going to develop your product with Qt. But barely has this choice been made when another presents itself. For your embedded GUI, is it better to use Qt Widgets or Qt Quick?
Why are there two choices? What's the point of developing two different technologies for the same purpose?
Qt Widgets is Qt's so-called historical user interface design solution.
You develop your GUI with "widgets" created in your application's C++ code.
Qt Quick is a solution that appeared later, with Qt 4.7.1.
The approach is different—this time your user interface code is separated from the rest of your application.
With Qt Quick comes a new language dedicated to this purpose: QML (Qt Markup Language).
But Qt Quick didn't signal the end of Qt Widgets. Indeed, even though framework development is now centered on Qt Quick, the two remain complementary and there's still at least one good reason to continue using the historical solution.
I'm Nathanaël Landais, an architect in IoT embedded software development. I've designed and developed embedded systems relying on open source components now distributed in hundreds of thousands of units around the world. Their common thread: modern and fluid user interfaces.
Qt Quick: Pros and Cons
Advantages
-
A modern technology actively developed by Qt
New features are still frequently added, constantly increasing the possibilities brought by this technology. -
User interfaces with a more modern look and more easily customizable
With Qt Quick and QML it's possible to choose from several themes provided directly with Qt.
Themes such as Google's "Material Design."
It's also very simple in QML to modify or create new custom UI elements. -
A true separation between your business code and GUI code.
Very clearly separating business code from user interface code is essential to prevent UI modifications from affecting the rest of the application's functionality.
Having a dedicated language for the user interface helps strengthen this separation. - Much faster UI development thanks to the specialized language
So there are many considerable advantages to using Qt Quick.
But there's also one main disadvantage: QML isn't C++, it's an interpreted language,
with a price to pay in resource consumption.
Qt Quick can compile your QML code into bytecode which must then be read and interpreted at runtime.
While using bytecode reduces resource consumption, it doesn't bring it down to that of pure C++ code. You should expect around 60 MB more memory footprint for Qt Quick compared to Qt Widgets.
The Qt Widgets Alternative
Advantages
- Native performance enabled by C++ development
-
No new language to learn
You stay in the same language as the rest of the application.
Disadvantages
- An old technology being abandoned to make way for Qt Quick
- User interface development is more laborious in C++ which isn't suited to this task
So, Qt Quick or Qt Widgets?
In the majority of cases, I'd answer Qt Quick—it's the current and future solution. Using Qt Widgets means limiting yourself to a past technology with more disadvantages than advantages. However, if your project has strong hardware constraints with very limited resources, Qt Quick may simply not be feasible. In that case Qt Widgets can be an alternative.
Still hesitating between the two? Contact us to discuss it. We'll analyze your product to see what's the best solution for you. If your choice is made, I've developed many products with Qt technologies and can support you in your development.
Have you thought about licensing? Qt is available under commercial and open source licenses. To help you, I wrote this article: Qt – Choosing Between Open Source and Commercial License!