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 1Qt Quick Controls
Stylable delegatesYesYes
Pre-built native stylesYesNo
Runtime style/theme changesYes 1Yes 2
Can be used on DesktopYesYes
Can be used on MobileYes 3Yes
Can be used on EmbeddedYes 3Yes
Internal event handlingQMLC++
  1. Not officially supported, but technically possible via private APIs
  2. Only themes for specific styles can be changed at runtime, styles are fixed
  3. 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 1Qt Quick ControlsAlternativesRemarks
ActionActionShortcut
(Qt Quick)
ApplicationWindowApplicationWindow
BusyIndicatorBusyIndicator
ButtonButton
CalendarMonthGrid,
DayOfWeekRow,
WeekNumberColumn
(Qt Labs Calendar)
  • Qt Labs Calendar: MonthGrid, DayOfWeek, and WeekNumberColumn are experimental unstyled building blocks for calendar views.
CheckBoxCheckBox
ComboBoxComboBox
ExclusiveGroupActionGroup,
ButtonGroup
(Qt Quick Controls)
  • Qt Quick Controls: ActionGroup and ButtonGroup offer similar functionality.
GroupBoxGroupBox
LabelLabel
MenuMenuMenu
(Qt Labs Platform)
  • Qt Quick Controls 1: Menu is native on platforms where an implementation is available in the Qt Platform Abstraction Layer. Other platforms use a QML-based top-level menu popup window. Menu supports traditional desktop style cascading submenus, but does not work on Embedded Linux because EGLFS does not support multiple top-level windows.
  • Qt Quick Controls: Menu is a non-native Item-based popup that is stacked above the application content. Due to this, menu popups are restricted within window boundaries. Menu is fully customizable using QML and Qt Quick, and allows adding any Items. Traditional desktop oriented features, such as cascading submenus and visualizing keyboard shortcuts are missing.
  • Qt Labs Platform: Menu is an experimental native menu that uses Qt Widgets as a fallback on platforms where a native implementation is not available in the Qt Platform Abstraction Layer.
MenuBarMenuBarMenuBar
(Qt Labs Platform)
  • Qt Quick Controls 1: MenuBar is native on platforms where an implementation is available in the Qt Platform Abstraction Layer. Other platforms use a QML-based menubar item stacked at the top of the window.
  • Qt Quick Controls: MenuBar is a non-native QML-based menubar that can be fully customized using QML and Qt Quick.
  • Qt Labs Platform: MenuBar is an experimental native menubar. It is only available on platforms where a native implementation is available in the Qt Platform Abstraction Layer.
MenuItem,
MenuSeparator
MenuItem,
MenuSeparator
MenuItem,
MenuSeparator
(Qt Labs Platform)
  • Qt Quick Controls 1: MenuItem and MenuSeparator are native on platforms where an implementation is available in the Qt Platform Abstraction Layer. Other platforms use QML-based menu items and separators.
  • Qt Quick Controls: MenuItem and MenuSeparator are a non-native QML-based menu items and separators that can be fully customized using QML and Qt Quick.
  • Qt Labs Platform: MenuItem and MenuSeparator are experimental native menu items and separators.
ProgressBarProgressBar
RadioButtonRadioButton
ScrollViewScrollView
SliderSlider
SpinBoxSpinBox
SplitViewSplitView
  • Qt Quick Controls 1: Uses Layout attached properties to specify size hints.
  • Qt Quick Controls: Uses dedicated SplitView attached properties to specify size hints. Allows saving and restoring state. Separate attached SplitHandle API for managing split handles.
StackView,
StackViewDelegate,
Stack
StackView
  • Qt Quick Controls: StackView provides customizable transitions and attached properties via a single StackView type.
StatusBarToolBar
(Qt Quick Controls)
  • Qt Quick Controls: ApplicationWindow allows assigning any item or control, such as ToolBar, as a header or footer.
SwitchSwitch
TabView,
Tab
TabBar,
TabButton
(Qt Quick Controls)
  • Qt Quick Controls: TabBar and TabButton offer similar functionality, and can be used to build tabbed views.
TableViewThe new TableView can be found in the Qt Quick module.
TextAreaTextArea
  • Qt Quick Controls 1: TextArea inherits ScrollView and is therefore always a scrollable editor.
  • Qt Quick Controls: TextArea is a simpler multi-line editor that can be optionally attached to a Flickable to provide scrolling functionality. This allows using TextArea in a scrollable page without having two nested scrollable areas, which can be problematic and cause usability issues.
TextFieldTextField
ToolBarToolBar
ToolButtonToolButton
TreeView
Qt Quick DialogsQt Quick ControlsAlternativesRemarks
DialogDialog
  • Qt Quick Dialogs: Dialog is either a top-level window or an Item-based popup depending on whether the underlying platform supports multiple top-level windows.
  • Qt Quick Controls: Dialog is not a top-level window, but an Item-based popup that is stacked above the application content. Due to this, dialogs are restricted within window boundaries.
ColorDialog,
FileDialog,
FontDialog,
MessageDialog
ColorDialog,
FileDialog,
FolderDialog,
FontDialog,
MessageDialog
(Qt Labs Platform)
  • Qt Quick Dialogs: Dialogs are native on platforms where an implementation is available in the Qt Platform Abstraction Layer. Other platforms use either Qt Widgets or QML-based dialogs depending on whether the underlying platform supports multiple top-level windows.
  • Qt Labs Platform: Experimental native dialogs that use Qt Widgets as a fallback on platforms where a native implementation is not available in the Qt Platform Abstraction Layer.
Qt Quick ExtrasQt Quick ControlsAlternativesRemarks
CircularGauge
DelayButtonDelayButton
DialDial
Gauge
Picture
PieMenu
StatusIndicator
ToggleButton
Tumbler,
TumblerColumn
Tumbler
  • Qt Quick Extras: Tumbler can consist of multiple columns.
  • Qt Quick Controls: Tumbler presents a single spinnable wheel. Multiple columns can be created by placing multiple Tumblers next to each other.
No PredecessorQt Quick ControlsAlternativesRemarks
AbstractButton
ActionGroupExclusiveGroup
(Qt Quick Controls 1)
  • Qt Quick Controls 1: ExclusiveGroup offers similar functionality.
ButtonGroupExclusiveGroup
(Qt Quick Controls 1)
  • Qt Quick Controls 1: ExclusiveGroup offers similar functionality.
CheckDelegate
Container
Control
Drawer
Frame
ItemDelegate
Page
PageIndicator
Pane
Popup
RadioDelegate
RangeSlider
RoundButton
ScrollBar,
ScrollIndicator
ScrollView
(Qt Quick Controls 1)
  • Qt Quick Controls 1: ScrollView offers similar functionality. It combines horizontal and vertical scrollbars, and the background and frame around the scrollable view.
StandardPaths
(Qt Labs Platform)
  • Qt Quick Dialogs: FileDialog offers a shortcut property that can be used to access the most common standard paths.
  • Qt Labs Platform: StandardPaths offers a separate type to give full access to the standard paths.
SwipeDelegate
SwipeView
SwitchDelegate
SystemTrayIcon
(Qt Labs Platform)
  • Qt Labs Platform: SystemTrayIcon is an experimental native system tray icon that uses Qt Widgets as a fallback on platforms where a native implementation is not available in the Qt Platform Abstraction Layer.
TabBar,
TabButton
TabView
(Qt Quick Controls 1)
  • Qt Quick Controls 1: TabView offers similar functionality. It combines the tab bar, background and frame around the tabs.
ToolSeparator
ToolTip
  • Qt Quick Controls 1: Button and Action have built-in Qt Widgets-based tooltips.
  • Qt Quick Controls: ToolTip can be attached to any Item.