当点击请添写工具名称时,光标移动到如下:
添加文字后,请填写工具名称消失:
同时设置添加文字的上限是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;
}
}
}
}
}