第14章:QML之TextInput

1,输入窗口
2,源码

import QtQuick 2.0

FocusScope{
    property alias label: label.text           //定义属性别名
    property alias text: input.text

    Row{
        spacing: 5

        Text{
            id: label
            text: "标签"
        }

        Rectangle{
            width: 100
            height: 20
            color: "white"                      //白底色
            border.color: "gray"                //灰色边框
            TextInput{
                id: input
                anchors.fill: parent
                anchors.margins: 4
                focus: true
                text: "请输入内容"
            }
        }
    }
}

import QtQuick 2.6

Rectangle {
    property alias mouseArea: mouseArea

    width: 360
    height: 360

    MouseArea {
        id: mouseArea
        anchors.fill: parent
    }

    TextBox {
        id: tBx1
        x: 25; y: 25
        focus: true
        label: "学号"
        text: focus ? "" : "请输入内容..."
        KeyNavigation.tab: tBx2
    }

    TextBox {
        id: tBx2
        x: 25; y: 60
        label: "姓名"
        text: focus ? "" : "请输入内容..."
        KeyNavigation.tab: tBx1
    }


}

3,效果
第14章:QML之TextInput