use*_*174 3 qt textinput qml qt-quick
如何TextInput在qml中将in 分配给int?
int new_span_seconds
TextInput {
id: editor
width: 80
height: 17
color: "white"
font.bold: true; font.pixelSize: 14
text: "21"
horizontalAlignment: TextInput.AlignHCenter
}
Keys.forwardTo: [ (returnKey), (editor)]
Item {
id: returnKey
Keys.onReturnPressed: new_span_seconds = editor. <<< ? >>>
Keys.onEnterPressed: new_span_seconds = editor. <<< ? >>>
}
Run Code Online (Sandbox Code Playgroud)
这只是一段Javascript
Keys.onReturnPressed: new_span_seconds = parseInt(editor.text)
Run Code Online (Sandbox Code Playgroud)