qml中TextField实现添加文字的上限,同时添加文字时,提示文字消失。
2018-01-21 14:32
1366 查看
当点击请添写工具名称时,光标移动到如下:
添加文字后,请填写工具名称消失:
同时设置添加文字的上限是31个字符,当超过31个就不能再添加。
相关代码:
import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.4 Rectangle{ id:toolsDisp; width:250; height:60; //设置工具名称 function setTaskName( name ){ taskName.text = name ; } function getToolsName(){ return toolsName.text; } function setToolName(name){ toolsName.text=name; } Row{ spacing: 10; anchors.top: parent.top; anchors.topMargin: 10; Column{ id:taskNameColumn Text{ id:taskNameHead text:"任务" font.pointSize: 12 font.bold: true } Text{ id:taskName; anchors.top: taskNameHead.bottom anchors.topMargin: 5 text:"模板1" font.pointSize: 8 color: "#313a4b" } } Column{ id:toolNameColumn; anchors.left: taskNameColumn.right anchors.leftMargin: 100 Text{ id:toolsNameHead; text:"工具名称" font.pointSize: 12 font.bold: true } TextField{ id:toolsName; //text: "请填写工具名称" placeholderText: "请填写工具名称" font.pointSize: 8 textColor:"#313a4b" maximumLength:31 style: TextFieldStyle{ background: Rectangle{ opacity: 1; } } } } }
相关文章推荐
- Ext.TextField自定义验证函数以及提示文字
- JS实现输入框提示文字点击时消失效果
- Android TextView富文本、超链接和添加文字背景等其他效果的实现
- TextView 部分文字高亮、点击、添加超链接、替换字体、富文本、图片替换文字等实现
- android--将editText中提示文字放到右边且不消失的简单做法
- ArcGIS API for Silverlight 动态添加点的同时,添加文字说明(利用TextSymbol添加多文字信息 )
- 怎么实现点击textbox后textbox里用于提示的文字消失
- IOS开发:对TextField或TextView添加文字限制
- iOS-textField左侧添加图片/文本框的文字与左侧添加空隙
- Extjs中如何在一行textfield后面增加文字提示
- jQuery实现文本域内提示文字,当鼠标点击进文本域后自动消失,文本域失去鼠标焦点后显示提示文字或显示用户输入的文字。
- jQuery实现文本域提示文字点击后消失
- 实现网页文本框显示灰色提示文字且点击后消失的一个小函数(基于jquery)
- 如何给 textview添加类似于textfield的水印文字
- HTML中输入框添加提示文字并且点击消失
- iOS - 实现TextView提示文字并且输入字数限制
- 用JS来实现输入框提示文字点击时消失
- 重写ext的TextField控件,增加鼠标悬浮提示和控件后加说明文字
- ArcGIS API for Silverlight 动态添加点的同时,添加文字说明(利用TextSymbol添加多文字信息 )
- HTML-input文本框(添加提示文字,填写内容时消失)