QML 中定义信号

QML 中定义型号

定义一个组件

EditText.qml

Item {
    property alias text: textField.text
    signal changeText(string text)

    TextField{
        id:textField
        onTextChanged: changeText(text)
    }
}

使用

main.qml

    EditText{

        onChangeText: {

            console.log(text)
        }

    }

结果

输入 helloworld 在删除

qml: h

qml: he

qml: hel

qml: hell

qml: hello

qml: hellow

qml: hellowo

qml: hellowor

qml: helloworl

qml: helloworld

qml: helloworl

qml: hellowor

qml: hellowo

qml: hellow

qml: hello

qml: hell

qml: hel

qml: he

qml: h

qml: 

你可能感兴趣的:(QT,QML)