Reputation: 107
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 ?
Upvotes: 3
Views: 7259
Reputation: 4198
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
Upvotes: 4