Differences with Qt Quick Controls 1
Qt Quick Controls 1 was originally developed to support desktop platforms, with mobile and embedded support coming shortly afterwards. They have a very broad scope, in that they provide a styling system flexible enough to allow the development of applications that have either a platform-dependent or platform-independent style.
On embedded systems, where the hardware has limited resources, this approach can be inefficient. Qt Quick Controls was designed to solve this problem, using benchmarks to guide the development.
C++ and QML
In many cases, the internal state of a control can be more efficiently processed in C++. For example, handling input events in C++ makes a difference for controls that would otherwise need to create internal MouseAreas and attached Keys objects.
Styles
Not only does handling events and logic in C++ increase performance, but it allows the visual QML layer to be a simple, declarative layer on top. This is reflected in the structure of the controls project: all visual implementations sit in the imports folder, so that users who want to create their own complete style can copy the folder and start tweaking. Read more about implementing a style plugin here.
In Qt Quick Controls, styles no longer provide components that are dynamically instantiated by controls, but controls themselves consist of item delegates that can be replaced. In effect, this means that delegates are Qt Quick items that are instantiated on the spot, as properties of the control, and are simply parented to the control.
Modularity and Simplicity
When it comes to more complex controls, it is sometimes better to split them up into separate building blocks. As an example, the complex ScrollView control:
ScrollView { horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff Flickable { // ... } }
Is replaced with simple ScrollBar/ScrollIndicator controls that can be attached to any Flickable:
Flickable { // ... ScrollBar.vertical: ScrollBar { } }
The API of Qt Quick Controls aims to be clean and simple. Common operations are easy, and more advanced ones are liberally documented with snippets that can be copied into your code.
Feature Comparison Table
Qt Quick Controls 1 | Qt Quick Controls | |
---|---|---|
Stylable delegates | Yes | Yes |
Pre-built native styles | Yes | No |
Runtime style/theme changes | Yes 1 | Yes 2 |
Can be used on Desktop | Yes | Yes |
Can be used on Mobile | Yes 3 | Yes |
Can be used on Embedded | Yes 3 | Yes |
Internal event handling | QML | C++ |
- Not officially supported, but technically possible via private APIs
- Only themes for specific styles can be changed at runtime, styles are fixed
- Performance may not be optimal
Porting Qt Quick Controls 1 Code
The API of Qt Quick Controls is very similar to Qt Quick Controls 1, but it does come with some changes necessary to facilitate the improvements. The majority of changes are to do with styling; all of a control's delegates are now accessible in the control itself, instead of in a separate style object.
For example, to style a button in Qt Quick Controls 1:
Button { style: ButtonStyle { label: Label { // ... } } }
To style a button in Qt Quick Controls:
Button { contentItem: Label { // ... } }
Preparing for Migration
With this in mind, a good way to prepare for a migration to Qt Quick Controls 2 is to place each control that you have a custom style for in its own QML file. For example, the Qt Quick Controls 1 button above could be moved to a file named Button.qml
in a directory named controls
, and used in the following manner:
import "controls" as Controls Controls.Button { // ... }
This works with both modules, and will reduce the amount of work needed when the migration begins.
Type Comparison Table
The first column lists all types available in Qt Quick Controls 1, Qt Quick Dialogs, and Qt Quick Extras. The second column documents the respective type in Qt Quick Controls. When a direct alternative is not available, the third column contains an alternative that provides related functionality. The last column contains some remarks about the differences between the types in the different modules.
Qt Quick Controls 1 | Qt Quick Controls | Alternatives | Remarks |
---|---|---|---|
Action | Action | Shortcut (Qt Quick) | |
ApplicationWindow | ApplicationWindow | ||
BusyIndicator | BusyIndicator | ||
Button | Button | ||
Calendar | — | MonthGrid, DayOfWeekRow, WeekNumberColumn (Qt Labs Calendar) |
|
CheckBox | CheckBox | ||
ComboBox | ComboBox | ||
ExclusiveGroup | — | ActionGroup, ButtonGroup (Qt Quick Controls) |
|
GroupBox | GroupBox | ||
Label | Label | ||
Menu | Menu | Menu (Qt Labs Platform) |
|
MenuBar | MenuBar | MenuBar (Qt Labs Platform) |
|
MenuItem, MenuSeparator | MenuItem, MenuSeparator | MenuItem, MenuSeparator (Qt Labs Platform) |
|
ProgressBar | ProgressBar | ||
RadioButton | RadioButton | ||
ScrollView | ScrollView | ||
Slider | Slider | ||
SpinBox | SpinBox | ||
SplitView | SplitView |
| |
StackView, StackViewDelegate, Stack | StackView |
| |
StatusBar | — | ToolBar (Qt Quick Controls) |
|
Switch | Switch | ||
TabView, Tab | — | TabBar, TabButton (Qt Quick Controls) |
|
TableView | — | The new TableView can be found in the Qt Quick module. | |
TextArea | TextArea |
| |
TextField | TextField | ||
ToolBar | ToolBar | ||
ToolButton | ToolButton | ||
TreeView | — | ||
Qt Quick Dialogs | Qt Quick Controls | Alternatives | Remarks |
Dialog | — | Dialog |
|
ColorDialog, FileDialog, FontDialog, MessageDialog | — | ColorDialog, FileDialog, FolderDialog, FontDialog, MessageDialog (Qt Labs Platform) |
|
Qt Quick Extras | Qt Quick Controls | Alternatives | Remarks |
CircularGauge | — | ||
DelayButton | DelayButton | ||
Dial | Dial | ||
Gauge | — | ||
Picture | — | ||
PieMenu | — | ||
StatusIndicator | — | ||
ToggleButton | — | ||
Tumbler, TumblerColumn | Tumbler |
| |
No Predecessor | Qt Quick Controls | Alternatives | Remarks |
— | AbstractButton | ||
— | ActionGroup | ExclusiveGroup (Qt Quick Controls 1) |
|
— | ButtonGroup | ExclusiveGroup (Qt Quick Controls 1) |
|
— | CheckDelegate | ||
— | Container | ||
— | Control | ||
— | Drawer | ||
— | Frame | ||
— | ItemDelegate | ||
— | Page | ||
— | PageIndicator | ||
— | Pane | ||
— | Popup | ||
— | RadioDelegate | ||
— | RangeSlider | ||
— | RoundButton | ||
— | ScrollBar, ScrollIndicator | ScrollView (Qt Quick Controls 1) |
|
— | — | StandardPaths (Qt Labs Platform) |
|
— | SwipeDelegate | ||
— | SwipeView | ||
— | SwitchDelegate | ||
— | — | SystemTrayIcon (Qt Labs Platform) |
|
— | TabBar, TabButton | TabView (Qt Quick Controls 1) |
|
— | ToolSeparator | ||
— | ToolTip |
|
Related Information
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.