[SailfishDevel] string to double in QML?

mariusz sapinski mariusz.sapinski at gmail.com
Sat May 21 04:44:02 UTC 2016


   I'm trying to convert text from a text field:

                 TextField {
                    id: ekField
                    width: 480
                    placeholderText: "Kinetic energy [MeV/u]"
                    EnterKey.enabled: text.length > 0
                    EnterKey.iconSource: "image://theme/icon-m-enter-accept"
                    EnterKey.onClicked: focus = false
                    //InputMethodHints: Qt.ImhFormattedNumbersOnly
                    validator: DoubleValidator {bottom: 0.00001}

to double (property double ekpu)

             onClicked: {
                 # ekpu=double(ekField.text)  # does not work
                 # gives: QString not declared even if there is #include
<QString> in main.cpp


How to do this? Must be trivial, but I googled for a reasonable amount of
time and found nothing.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20160521/bfdb1864/attachment.html>

More information about the Devel mailing list