QML - How to Resize TextField Font

How to set font size of TextField element in QML? want to change the size placeholderText, as well as the text that the user enters.

I tried many ways with no luck!

TextField {
    id: name_TextField; horizontalAlignment: Text.AlignHCenter;
    Layout.preferredWidth: parentCLayer.width * 0.90; Layout.preferredHeight: 50
    style: TextFieldStyle {
        font.pixelSize: 20  // This doesn't seem to work either
    }
    placeholderText: qsTr("Your name here")
}
+2
source share
2 answers

You can use the property stylefor customization TextField. For instance:

TextField {
    style: TextFieldStyle {
        font.pixelSize: 14
    }
}

I tried and it works like a charm

+2
source

Using Element fontfor TextField

TextField font, QML font. font TextField, , . , TextField, .

TextField {
    font.pointSize: 20
    font.bold: true
    font.family: "Times New Roman"
    textColor: "red"
}

Default TextField Style

TextField style at 20pt, bold Times New Roman.

style TextField

TextField, TextFieldStyle style TextField. TextFieldStyle font, IDE , , , QTCREATORBUG-11186. , font :

TextField {
    style: TextFieldStyle {
        background: Rectangle {
            color: "red"
            radius: 10
        }
        font {
            bold: true
            pointSize: 22
        }
        textColor: "white"
    }
}

, # 11186 , , , font TextFieldStyle null; - Qt/QML .

: http://wiki.qt.io/Qml_Styling

0

Source: https://habr.com/ru/post/1651868/


All Articles