AbstractButton

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

Import Statement: import QtQuick.Controls 2.4
Since: Qt 5.7
Inherits:

Control

Inherited By:

Button, CheckBox, DelayButton, ItemDelegate, MenuBarItem, MenuItem, RadioButton, Switch, and TabButton

Properties

Signals

Methods

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

action : Action

This property holds the button action.

This QML property was introduced in QtQuick.Controls 2.3 (Qt 5.10).

See also Action.


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.


autoRepeat : bool

This property holds whether the button repeats pressed(), released() and clicked() signals while the button is pressed and held down.

The default value is false.

The initial delay and the repetition interval are defined in milliseconds by autoRepeatDelay and autoRepeatInterval.


autoRepeatDelay : int

This property holds the initial delay of auto-repetition in milliseconds. The default value is 300 ms.

This QML property was introduced in QtQuick.Controls 2.4 (Qt 5.11).

See also autoRepeat and autoRepeatInterval.


autoRepeatInterval : int

This property holds the interval of auto-repetition in milliseconds. The default value is 100 ms.

This QML property was introduced in QtQuick.Controls 2.4 (Qt 5.11).

See also autoRepeat and autoRepeatDelay.


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.


display : enumeration

This property determines how the icon and text are displayed within the button.

Display Result
AbstractButton.IconOnly

AbstractButton.TextOnly

AbstractButton.TextBesideIcon

AbstractButton.TextUnderIcon

This QML property was introduced in QtQuick.Controls 2.3 (Qt 5.10).

See also spacing and padding.


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.


icon group

icon.name : string

icon.source : url

icon.width : int

icon.height : int

icon.color : color

This property group was added in QtQuick.Controls 2.3.

Name Description
name This property holds the name of the icon to use.

The icon will be loaded from the platform theme. If the icon is found in the theme, it will always be used; even if icon.source is also set. If the icon is not found, icon.source will be used instead.

For more information on theme icons, see QIcon::fromTheme().

source This property holds the name of the icon to use.

The icon will be loaded as a regular image.

If icon.name is set and refers to a valid theme icon, it will always be used instead of this property.

width This property holds the width of the icon.

The icon's width will never exceed this value, though it will shrink when necessary.

height This property holds the height of the icon.

The icon's height will never exceed this value, though it will shrink when necessary.

color This property holds the color of the icon.

The icon is tinted with the specified color, unless the color is set to "transparent".

See also text, display, and Icons in Qt Quick Controls 2.


indicator : Item

This property holds the indicator item.


[read-only] pressX : real

This property holds the x-coordinate of the last press.

Note: The value is updated on touch moves, but left intact after touch release.

This QML property was introduced in QtQuick.Controls 2.4 (Qt 5.11).

See also pressY.


[read-only] pressY : real

This property holds the y-coordinate of the last press.

Note: The value is updated on touch moves, but left intact after touch release.

This QML property was introduced in QtQuick.Controls 2.4 (Qt 5.11).

See also pressX.


[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 icon, display, and contentItem.


Signal Documentation

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.


clicked()

This signal is emitted when the button is interactively clicked by the user via touch, mouse, or keyboard.


doubleClicked()

This signal is emitted when the button is interactively double clicked by the user via touch or mouse.


pressAndHold()

This signal is emitted when the button is interactively pressed and held down by the user via touch or mouse.


pressed()

This signal is emitted when the button is interactively pressed by the user via touch, mouse, or keyboard.


released()

This signal is emitted when the button is interactively released by the user via touch, mouse, or keyboard.


toggled()

This signal is emitted when a checkable button is interactively toggled by the user via touch, mouse, or keyboard.

This QML signal was introduced in QtQuick.Controls 2.2 (Qt 5.9).


Method Documentation

void toggle()

Toggles the checked state of the button.


Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support