Switch QML Type | Qt Labs Controls 5.6

Qt 5.6 | Qt Labs Controls | QML Types | Switch QML Type

Qt 5.6.2 Reference Documentation

# Switch QML Type

A switch control. More...

Import Statement: | import Qt.labs.controls 1.0
Inherits: | AbstractButton

- List of all members, including inherited members

## Properties

- position : real
- visualPosition : real

## Detailed Description

Switch is an option button that can be dragged or toggled on (checked) or off (unchecked). Switches are typically used to select between two states.

| A switch in its normal state.
| A switch that is checked.
| A switch that has active focus.
| A switch that is disabled.

      ColumnLayout {
          Switch {
              text: qsTr("Wi-Fi")
          }
          Switch {
              text: qsTr("Bluetooth")
          }
      }

Note: Types in the Qt.labs module are not guaranteed to remain compatible in future versions.

See also Customizing Switch and Button Controls.

## Property Documentation

[read-only] position : real

This property holds the logical position of the thumb indicator.

The position is defined as a percentage of the control's size, scaled to `0.0` - `1.0`. The position can be used for example to determine whether the thumb has been dragged past the halfway. For visualizing a thumb indicator, the right-to-left aware visualPosition should be used instead.

See also visualPosition.

[read-only] visualPosition : real

This property holds the visual position of the thumb indicator.

The position is defined as a percentage of the control's size, scaled to `0.0` - `1.0`. When the control is mirrored, the value is equal to `1.0 - position`. This makes the value suitable for visualizing the thumb indicator taking right-to-left support into account. In order to for example determine whether the thumb has been dragged past the halfway, the logical position should be used instead.

See also position.