Development/Tutorials/Graphics/Migrate Qt Quick Controls 1

From KDE TechBase
Revision as of 22:26, 18 October 2019 by Guoyunhe (talk | contribs)

Import

import QtQuick.Controls 1.4

to

import QtQuick.Controls 2.8

Icon

Button {
    iconName: "file-new"
    iconSource: "my-file-new.svg"
}

to

Button {
    icon.name: "file-new"
    icon.source: "my-file-new.svg"
}

ToolTip

Button {
    tooltip: "Create new file"
}

to

Button {
    ToolTip.visible: hovered
    ToolTip.text: "Create new file"
}

ExclusiveGroup

ExclusiveGroup { id: filterGroup}

Button {
    exclusiveGroup: filterGroup
}
Button {
    exclusiveGroup: filterGroup
}

to

ButtonGroup { id: filterGroup}

Button {
    ButtonGroup.group: filterGroup
}
Button {
    ButtonGroup.group: filterGroup
}

SplitView

You need at least Qt 5.13 and QtQuick.Controls 2.13. For older system, this might not be supported. You can use RowLayout/ColumnLayout instead if you want to lower system requirements.

SpinBox

The interface in Qt Quick Controls 2 is totally different, especially how decimals are supported. You have to rewrite the whole part following the new documentation.

TableView

You need at least Qt 5.13 and QtQuick.Controls 2.13. The interface is different. You need to rewrite some part of it.

Examples