使用Qt Quick Controls 1,有没有办法改变QML中RadioButton的文本颜色?
我想将其更改为白色,因为我的背景是黑色,找不到方法。
RowLayout {
RadioButton {
width:15
height:15
text: "xlsx"
checked: true
}
RadioButton {
width:15
height:15
text: "Bottom"
}
}
最佳答案
对于 Qt Quick Controls 2,您应该使用自定义 contentItem
创建自己的 RadioButton
组件:
RadioButton {
id: control
width: 15
height: 15
text: "xlsx"
contentItem: Text {
text: control.text
color: "white"
leftPadding: control.indicator.width + control.spacing
verticalAlignment: Text.AlignVCenter
}
}
请参阅文档中的完整示例:Customizing RadioButton .
对于 Qt Quick Controls 1,请参阅 @Roya Ghasemzadeh 的回答。
关于qt - 更改 QML 的 RadioButton 中文本的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56111419/