[英]Option style (Dropdown, RadioGroup, etc) in QML or C++ (Cascades)
I'm trying to set a custom style to a group of options belonging to a dropdown or a Radio Group. 我试图将自定义样式设置为属于下拉列表或Radio Group的一组选项。 I'm searching all over and it seems impossible. 我到处搜寻,似乎不可能。 At least I would like to decrease the size of the letters in the text of each option because is too big! 至少我想减小每个选项文本中字母的大小,因为太大了! and crashes my UI. 并崩溃了我的用户界面。
Here's and example of what I need: 这是我需要的示例:
RadioGroup {
id: groupOrigin
objectName: "groupOrigin"
Option{
text: "text to display"
//This text default style is what I'm trying to change. Please help!.
}
}
thanks! 谢谢!
for Radio group you can achieve this using custom implementation. 对于Radio组,您可以使用自定义实现来实现。 Take a label and place it after the radio group did not provide text inside the options tag. 采取标签并将其放置在无线电组未在options标签内提供文本之后。 So whatever style you want to apply can be done using label. 因此,无论您要应用哪种样式,都可以使用label来完成。
On label you can set the font size, color and other style parameter you want to apply. 在标签上,您可以设置要应用的字体大小,颜色和其他样式参数。
Please check the source code below for this custom radio button. 请检查以下自定义单选按钮的源代码。 I did this in the QML you can achieve same in C++. 我在QML中做到了这一点,您可以在C ++中实现相同的目的。
// The Component title.
Label {
id: titleLabel
text: ""
textStyle {
base: SystemDefaults.TextStyles.SmallText
alignment: TextAlignment.Center
}
layoutProperties: StackLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
}
}
// The radio group presenting the different curves.
RadioGroup {
id: radioGroup
Option {
text: "Height"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.