Qt 5.8 | Qt Quick Controls 2 | QML Types | AbstractButton QML Type

Qt 5.8.0 Reference Documentation

# AbstractButton QML Type

Abstract base type providing functionality common to buttons. More...

Import Statement: | import QtQuick.Controls 2.1
Since: | Qt 5.7

- List of all members, including inherited members

## Properties

- autoExclusive : bool
- checkable : bool
- checked : bool
- down : bool
- indicator : Item
- pressed : bool
- text : string

## Signals

- void canceled()
- void clicked()
- void doubleClicked()
- void pressAndHold()
- void pressed()
- void released()

## Methods

- void toggle()

## Detailed Description

AbstractButton provides the interface for controls with button-like behavior; for example, push buttons and checkable controls like radio buttons and check boxes. As an abstract control, it has no delegate implementations, leaving them to the types that derive from it.

See also ButtonGroup and Button Controls.

## Property Documentation

autoExclusive : bool

This property holds whether auto-exclusivity is enabled.

If auto-exclusivity is enabled, checkable buttons that belong to the same parent item behave as if they were part of the same ButtonGroup. Only one button can be checked at any time; checking another button automatically unchecks the previously checked one.

Note: The property has no effect on buttons that belong to a ButtonGroup.

RadioButton and TabButton are auto-exclusive by default.

checkable : bool

This property holds whether the button is checkable.

A checkable button toggles between checked (on) and unchecked (off) when the user clicks on it or presses the space bar while the button has active focus.

Setting checked to `true` forces this property to `true`.

The default value is `false`.

See also checked.

checked : bool

This property holds whether the button is checked.

See also checkable.

down : bool

This property holds whether the button is visually down.

Unless explicitly set, this property follows the value of pressed. To return to the default value, set this property to `undefined`.

See also pressed.

indicator : Item

This property holds the indicator item.

[read-only] pressed : bool

This property holds whether the button is physically pressed. A button can be pressed by either touch or key events.

See also down.

text : string

This property holds a textual description of the button.

Note: The text is used for accessibility purposes, so it makes sense to set a textual description even if the content item is an image.

See also contentItem.

## Signal Documentation

void canceled()

This signal is emitted when the button loses mouse grab while being pressed, or when it would emit the released signal but the mouse cursor is not inside the button.

void clicked()

This signal is emitted when the button is interactively clicked by the user.

void doubleClicked()

This signal is emitted when the button is interactively double clicked by the user.

void pressAndHold()

This signal is emitted when the button is interactively pressed and held down by the user.

void pressed()

This signal is emitted when the button is interactively pressed by the user.

void released()

This signal is emitted when the button is interactively released by the user.

## Method Documentation

void toggle()

Toggles the checked state of the button.