AbstractButton QML Type

Abstract base type providing functionality common to buttons. 更多...

import 语句: import QtQuick.Controls
继承:

Control

继承者:

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

特性

信号

方法

详细描述

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.

另请参阅 ButtonGroup and 按钮控件 .

特性文档编制

action : 动作 [since QtQuick.Controls 2.3 (Qt 5.10)]

This property holds the button action.

该特性在 QtQuick.Controls 2.3 (Qt 5.10) 引入。

另请参阅 动作 .

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.

注意: 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 () 和 clicked () signals while the button is pressed and held down.

If this property is set to true pressAndHold () signal will not be emitted.

默认值为 false .

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

autoRepeatDelay : int [since QtQuick.Controls 2.4 (Qt 5.11)]

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

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

另请参阅 autoRepeat and autoRepeatInterval .

autoRepeatInterval : int [since QtQuick.Controls 2.4 (Qt 5.11)]

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

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

另请参阅 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.

默认值为 false .

另请参阅 checked .

checked : bool

This property holds whether the button is checked.

Since Qt 6.2, setting this property no longer affects the checkable property. Explicitly set the checkable property if needed.

另请参阅 checkable .

display : enumeration [since QtQuick.Controls 2.3 (Qt 5.10)]

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

显示 结果
AbstractButton.IconOnly
AbstractButton.TextOnly
AbstractButton.TextBesideIcon (默认)
AbstractButton.TextUnderIcon

该特性在 QtQuick.Controls 2.3 (Qt 5.10) 引入。

另请参阅 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 .

另请参阅 pressed .

icon group

icon.cache : bool

icon.color : color

icon.height : int

icon.name : string

icon.source : url

icon.width : int

This property group was added in QtQuick .Controls 2.3.

名称 描述
名称

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.

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" .

cache

This property specifies whether the icon should be cached.

默认值为 true。

更多信息,见 cache .

This property was introduced in QtQuick .Controls 2.13.

另请参阅 text , display ,和 Icons in Qt Quick Controls .

implicitIndicatorHeight : real [read-only, since QtQuick.Controls 2.5 (Qt 5.12)]

This property holds the implicit indicator height.

值等于 indicator ? indicator.implicitHeight : 0 .

This is typically used, together with implicitContentHeight and implicitBackgroundHeight , to calculate the implicitHeight .

该特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。

另请参阅 implicitIndicatorWidth .

implicitIndicatorWidth : real [read-only, since QtQuick.Controls 2.5 (Qt 5.12)]

This property holds the implicit indicator width.

值等于 indicator ? indicator.implicitWidth : 0 .

This is typically used, together with implicitContentWidth and implicitBackgroundWidth , to calculate the implicitWidth .

该特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。

另请参阅 implicitIndicatorHeight .

indicator : Item

This property holds the indicator item.

pressX : real [read-only, since QtQuick.Controls 2.4 (Qt 5.11)]

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

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

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

另请参阅 pressY .

pressY : real [read-only, since QtQuick.Controls 2.4 (Qt 5.11)]

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

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

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

另请参阅 pressX .

pressed : bool [read-only]

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

另请参阅 down .

text : string

This property holds a textual description of the button.

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

另请参阅 icon , display ,和 contentItem .

信号文档编制

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.

注意: 相应处理程序是 onCanceled .

clicked ()

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

注意: 相应处理程序是 onClicked .

另请参阅 Call a C++ function from QML when a Button is clicked .

doubleClicked ()

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

注意: 相应处理程序是 onDoubleClicked .

pressAndHold ()

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

注意: 相应处理程序是 onPressAndHold .

pressed ()

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

注意: 相应处理程序是 onPressed .

released ()

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

注意: 相应处理程序是 onReleased .

[since QtQuick.Controls 2.2 (Qt 5.9)] toggled ()

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

注意: 相应处理程序是 onToggled .

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

方法文档编制

void toggle ()

Toggles the checked state of the button.