Override Material Style for an individual control?



  • I've set my QtQuick Controls 2 app to use Material style.

    As an unfortunate side effect of this, all button text is capitalized, even if text is set to a lowercase string.

    Is there a way to override the style set in the qtquickcontrols2.conf file for a particular control, so I can add lowercase text to my button?



  • Well...I found one solution...if I override the contentItem for the button

    contentItem: Text {
            text: myButton.text
            font.family:"helvetica"
            font.pointSize:16
            opacity: enabled ? 1.0 : 0.3
            color: control.down ? "#17a81a" : "#21be2b"
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            elide: Text.ElideRight
        }
    

    But if I simply set the font to be myButton.font, then I'll get capitalized text.

    Is there a simpler way to override the Material Style?



  • The default font follows the Material Design guidelines:

    Button text should be capitalized in languages that have capitalization.

    In order to override the default, set font.capitalization:

    Button {
        text: "Button"
        font.capitalization: Font.MixedCase
    }

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.