I tried to pass a value inserted in textField in a C++ float
variable.
The following code is a representation of what I need.
TextField{id:textField1}
Button{onClicked:function.printFloat = textField1.text.toFloat}
but I received the following warning message:
qrc:/qml/window/WindowConfigTelemetry.qml:215: Error: Cannot assign QString to float
What is wrong in my code?
It's a bit hard with some parts of your code missing, but you can use the Javascript function parseInt
and parseFloat
console.log("integer: ", parseInt(textField1.text))
console.log("float: ", parseFloat(textField1.text))
See https://doc.qt.io/qt-5/qtqml-javascript-functionlist.html for more helpful functions
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.