Button
import { Button, VerticalBox } from "std-widgets.slint";export component Example inherits Window { width: 200px; height: 100px; VerticalBox { label := Text { text: "Button not clicked"; } Button { text: "Click Me"; clicked => { label.text = " Button clicked"; } } }}slint
一个简单的按钮。常见的按钮类型也可以通过 StandardButton 创建。
checkable
Section titled “checkable”booldefault: false
显示按钮是否可选中。这使 checked 属性有可能变为 true。
Button { text: "Checkable Button"; checkable: true;}slint
checked
Section titled “checked”bool(in-out)default: false
显示按钮是否已选中。需要 checkable 为 true 才能生效。
enabled
Section titled “enabled”booldefault: true
默认为 true。当为 false 时,按钮无法被按下。
has-focus
Section titled “has-focus”bool(out)
当按钮具有键盘焦点时设置为 true
imagedefault: the empty image
在按钮中显示的图片。请注意,并非所有样式都支持绘制图标。
icon-size
Section titled “icon-size”lengthdefault: 0px
按钮中显示的图标大小。默认值取决于样式。如果需要容纳较大的图标尺寸,按钮将自动增大。
pressed
Section titled “pressed”bool(out)
当按钮被按下时设置为 true。
primary
Section titled “primary”booldefault: false
如果设置为 true,按钮将使用主强调色显示。
colorize-icon
Section titled “colorize-icon”booldefault: false
如果设置为 true,图标将被着色为与 Button 文本颜色相同的颜色。
clicked()
Section titled “clicked()”在以下情况调用:手指或鼠标左键在此元素上按下,然后释放。
Button { text: "Click me"; clicked() => { debug("Button clicked"); }}slint
© 2026 SixtyFPS GmbH