AbstractButton QML Type
提供按钮通用功能的抽象基本类型。更多
Import Statement: | import QtQuick.Controls |
Inherits: | |
Inherited By: | Button, CheckBox, DelayButton, ItemDelegate, MenuBarItem, MenuItem, RadioButton, Switch, and TabButton |
属性
- action : Action
(since QtQuick.Controls 2.3 (Qt 5.10))
- autoExclusive : bool
- autoRepeat : bool
- autoRepeatDelay : int
(since QtQuick.Controls 2.4 (Qt 5.11))
- autoRepeatInterval : int
(since QtQuick.Controls 2.4 (Qt 5.11))
- checkable : bool
- checked : bool
- display : enumeration
(since QtQuick.Controls 2.3 (Qt 5.10))
- down : bool
- icon
- icon.cache : bool
- icon.color : color
- icon.height : int
- icon.name : string
- icon.source : url
- icon.width : int
- implicitIndicatorHeight : real
(since QtQuick.Controls 2.5 (Qt 5.12))
- implicitIndicatorWidth : real
(since QtQuick.Controls 2.5 (Qt 5.12))
- indicator : Item
- pressX : real
(since QtQuick.Controls 2.4 (Qt 5.11))
- pressY : real
(since QtQuick.Controls 2.4 (Qt 5.11))
- pressed : bool
- text : string
信号
- canceled()
- clicked()
- doubleClicked()
- pressAndHold()
- pressed()
- released()
- toggled()
(since QtQuick.Controls 2.2 (Qt 5.9))
方法
- void animateClick()
(since Qt 6.8)
- void click()
(since Qt 6.8)
- void toggle()
详细说明
AbstractButton 为具有类似按钮行为的控件提供了接口,例如按钮以及单选按钮和复选框等可选中控件。作为一个抽象控件,它没有委托实现,只能由派生类型来实现。
另请参阅 ButtonGroup 和按钮控件。
属性文档
action : Action |
autoExclusive : bool |
该属性显示是否启用了自动排他性。
如果启用了自动排他性,属于同一父项的可选中按钮的行为就如同它们是同一ButtonGroup 的一部分。任何时候只能选中一个按钮;选中另一个按钮会自动取消选中之前选中的按钮。
注: 该属性对属于ButtonGroup 的按钮不起作用。
RadioButton 和 默认为自动排他性。TabButton
autoRepeat : bool |
该属性用于保存按钮在按住时是否重复发送pressed(),released() 和clicked() 信号。
如果该属性设置为true
,则不会发出pressAndHold() 信号。
默认值为false
。
初始延迟和重复间隔由autoRepeatDelay 和autoRepeatInterval 定义,单位为毫秒。
autoRepeatDelay : int |
该属性以毫秒为单位保存自动重复的初始延迟。默认值为300
ms。
该属性在 QtQuick.Controls 2.4 (Qt 5.11) 中引入。
另请参阅 autoRepeat 和autoRepeatInterval 。
autoRepeatInterval : int |
该属性以毫秒为单位保存自动重复的时间间隔。默认值为100
ms。
该属性在 QtQuick.Controls 2.4 (Qt 5.11) 中引入。
另请参阅 autoRepeat 和autoRepeatDelay 。
checkable : bool |
checked : bool |
display : enumeration |
该属性组在QtQuick.Controls 2.3 中添加。
名称 | 名称 |
---|---|
名称 | 该属性包含要使用的图标名称。 图标将从平台主题中加载。如果在主题中找到该图标,则将始终使用该图标;即使icon.source 也已设置。如果找不到图标,则将使用icon.source 代替。 有关主题图标的更多信息,请参阅QIcon::fromTheme() 。 |
来源 | 该属性包含要使用的图标名称。 图标将作为普通图片加载。 如果icon.name 已设置并指向一个有效的主题图标,则将始终使用该图标而非该属性。 |
宽度 | 该属性表示图标的宽度。 图标的宽度永远不会超过此值,但必要时会缩小。 |
高度 | 该属性用于保存图标的高度。 图标的高度永远不会超过此值,但必要时会缩小。 |
颜色 | 该属性用于设置图标的颜色。 除非颜色设置为 |
缓存 | 此属性用于指定是否缓存图标。 默认值为 true。 更多信息,请参阅cache 。 该属性在QtQuick.Controls 2.13 中引入。 |
另请参阅 text,display, 以及 Qt Quick Controls 中的图标。
implicitIndicatorHeight : real |
该属性保存隐式指示符高度。
其值等于indicator ? indicator.implicitHeight : 0
。
它通常与implicitContentHeight 和implicitBackgroundHeight 一起用于计算implicitHeight 。
该属性在 QtQuick.Controls 2.5 (Qt 5.12) 中引入。
另请参阅 implicitIndicatorWidth 。
implicitIndicatorWidth : real |
该属性保存隐式指示器宽度。
其值等于indicator ? indicator.implicitWidth : 0
。
它通常与implicitContentWidth 和implicitBackgroundWidth 一起用于计算implicitWidth 。
该属性在 QtQuick.Controls 2.5 (Qt 5.12) 中引入。
另请参阅 implicitIndicatorHeight 。
indicator : Item |
该属性包含指标项。
pressX : real |
该属性保存最后一次按下的 x 坐标。
注意: 该值在触摸移动时更新,但在触摸释放后保持不变。
该属性在 QtQuick.Controls 2.4 (Qt 5.11) 中引入。
另请参阅 pressY 。
pressY : real |
该属性保存最后一次按下时的 y 坐标。
注意: 该值在触摸移动时更新,但在触摸释放后保持不变。
该属性在 QtQuick.Controls 2.4 (Qt 5.11) 中引入。
另请参阅 pressX 。
text : string |
信号文档
canceled() |
当按钮在按下时失去鼠标抓取功能,或本应发出released 信号但鼠标光标不在按钮内时,就会发出该信号。
注: 相应的处理程序是onCanceled
。
clicked() |
当用户通过触摸、鼠标或键盘交互式点击按钮时,将发出该信号。
注: 相应的处理程序是onClicked
。
另请参阅 click(),animateClick(), 以及点击按钮时从 QML 调用 C++ 函数。
doubleClicked() |
当用户通过触摸或鼠标交互双击按钮时,会发出该信号。
注: 相应的处理程序是onDoubleClicked
。
pressAndHold() |
当用户通过触摸或鼠标交互式地按住按钮时,会发出该信号。启用autoRepeat 时不会发出该信号。
注: 相应的处理程序是onPressAndHold
。
pressed() |
当用户通过触摸、鼠标或键盘以交互方式按下按钮时,将发出该信号。
注: 相应的处理程序是onPressed
。
released() |
当用户通过触摸、鼠标或键盘以交互方式释放按钮时,将发出该信号。
注: 相应的处理程序是onReleased
。
|
当用户通过触摸、鼠标或键盘交互式切换可复选按钮时,将发出该信号。
注: 相应的处理程序是onToggled
。
该信号在 QtQuick.Controls 2.2 (Qt 5.9) 中引入。
方法文档
|
模拟点击按钮,在按下和松开之间有 100 毫秒的延迟,并在此过程中对按钮的视觉状态进行动画处理。
与点击相关的所有信号都会酌情发出。
如果focusPolicy 包括Qt.ClickFocus
,activeFocus 将变为true
。
如果按钮是disabled ,则此函数不会执行任何操作。
在释放按钮之前再次调用该函数将重置释放计时器。
此方法在 Qt 6.8 中引入。
|
模拟点击按钮,按下和松开之间没有延迟。
与点击相关的所有信号都会酌情发出。
如果focusPolicy 包括Qt.ClickFocus
,activeFocus 将变为true
。
如果按钮是disabled ,则此函数不会执行任何操作。
在释放按钮之前再次调用该函数将重置释放计时器。
此方法在 Qt 6.8 中引入。
另请参阅 animateClick()、pressed()、released() 和clicked() 。
void toggle() |
切换按钮的选中状态。
另请参阅 click() 和animateClick()。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.