是否可以设置复选框中使用的文本大小?
我有以下代码:
CheckBox {
text: qsTr("Use Delays")
checked: false
anchors.horizontalCenter: parent.horizontalCenter
onCheckedChanged:
{
middle.useDelays = checked
}
}
非常感谢!
答案 0 :(得分:1)
您可以使用CheckBoxStyle.label
来定义Text
显示的CheckBox
项目
import QtQuick.Controls.Styles 1.4
CheckBox {
style: CheckBoxStyle {
label: Text {
text: "Label"
font.pointSize: 16
}
}
}
答案 1 :(得分:1)
对于QtQuick Controls 2
,您可以执行以下操作:
https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-checkbox
import QtQuick 2.12
import QtQuick.Controls 2.12
CheckBox {
id: control
text: qsTr("CheckBox")
checked: true
indicator: Rectangle {
implicitWidth: 26
implicitHeight: 26
x: control.leftPadding
y: parent.height / 2 - height / 2
radius: 3
border.color: control.down ? "#17a81a" : "#21be2b"
Rectangle {
width: 14
height: 14
x: 6
y: 6
radius: 2
color: control.down ? "#17a81a" : "#21be2b"
visible: control.checked
}
}
contentItem: Text {
text: control.text
font: control.font
opacity: enabled ? 1.0 : 0.3
color: control.down ? "#17a81a" : "#21be2b"
verticalAlignment: Text.AlignVCenter
leftPadding: control.indicator.width + control.spacing
}
}