QML-如何更改TextField字体大小 [英] QML - How to change TextField font size

查看:452
本文介绍了QML-如何更改TextField字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在QML中设置TextField元素的字体大小?想要更改placeholderText的大小以及用户输入的文本.

How can I set the font size of a TextField element in QML? wanna change size of the placeholderText and also for the text which the user enters.

我尝试了很多不走运的方法!

I tried with a lot of ways without 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")
}

推荐答案

您可以使用style属性来自定义TextField.例如:

You can use the style property to customize your TextField. For example:

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

我尝试过,它就像一个魅力

I tried it and it works like a charm

这篇关于QML-如何更改TextField字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆