繁体   English   中英

QML或C ++(级联)中的选项样式(Dropdown,RadioGroup等)

[英]Option style (Dropdown, RadioGroup, etc) in QML or C++ (Cascades)

我试图将自定义样式设置为属于下拉列表或Radio Group的一组选项。 我到处搜寻,似乎不可能。 至少我想减小每个选项文本中字母的大小,因为太大了! 并崩溃了我的用户界面。

这是我需要的示例:

RadioGroup {
 id: groupOrigin
 objectName: "groupOrigin"

 Option{
   text: "text to display" 
   //This text default style is what I'm trying to change. Please help!.
 }
}

谢谢!

对于Radio组,您可以使用自定义实现来实现。 采取标签并将其放置在无线电组未在options标签内提供文本之后。 因此,无论您要应用哪种样式,都可以使用label来完成。

在标签上,您可以设置要应用的字体大小,颜色和其他样式参数。

请检查以下自定义单选按钮的源代码。 我在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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM