Skip to content

CheckBox

import { CheckBox } from "std-widgets.slint";
export component Example inherits Window {
width: 200px;
height: 25px;
background: transparent;
CheckBox {
x: 5px;
width: parent.width;
height: parent.height;
text: "Hello World";
}
}
slint

使用 CheckBox 让用户选择或取消选择值,例如在具有多个选项的列表中。如果该操作更像是打开或关闭某物,请考虑改用 Switch 元素。

bool(in-out)default: false

复选框是否已选中。

CheckBox {
text: self.checked ? "Checked" : "Not checked";
checked: true;
}
slint

booldefault: true

默认为 true。当为 false 时,复选框无法被按下。

lengthdefault: 0px

标签文本的字体大小。

intdefault: 0

标签文本的字体粗细。

bool(out)

当复选框具有键盘焦点时设置为 true。

stringdefault: ""

复选框旁边显示的文本。

CheckBox {
text: "CheckBox with text";
}
slint

复选框的值发生了变化

CheckBox {
text: "CheckBox";
toggled() => {
debug("CheckBox checked: ", self.checked);
}
}
slint

© 2026 SixtyFPS GmbH