它可以是这样的:
QML 文件:
Item{
id: root
signal textChanged(string msg)
TextInput
{
id: inputText
anchors.horizontalCenter: root.horizontalCenter
anchors.verticalCenter: root.verticalCenter
text : ""
inputMethodHints: Qt.ImhNoPredictiveText
selectByMouse: true
onAccepted: {
inputText.focus = false;
Qt.inputMethod.hide();
root.textChanged(inputText.text);
}
}
}
Run Code Online (Sandbox Code Playgroud)
?您可以将 qml 的信号连接到 cpp 中的某个插槽,例如:
QObject::connect((QObject *)viewer.rootObject(), SIGNAL(textChanged(QString)), this, SLOT(someSlot(QString)));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3175 次 |
| 最近记录: |