[SailfishDevel] string to double in QML?

Peter Kovacs leginee at gmail.com
Sun May 22 03:17:58 UTC 2016


Hello,

# gives: QString not declared even if there is #include <QString> in
main.cpp
that is not sufficient!
Quoted from:
http://stackoverflow.com/questions/9500280/access-c-function-from-qml

For any C++ code to be called from QML, it must reside inside a QObject.

So best is to write your own class that holds the data, then have a method
that sets the double value and does the cast to double.

I personally would not do the conversion in the QML part, because the QML
main task is to represent something. The tast of your data class is to care
about the data.
Looks nicer in my eyes if you have a class that handles this properly.

All the Best
Peter


2016-05-21 11:06 GMT+02:00 Caliste Damien <dcaliste at free.fr>:

> Hello,
>
> Le samedi 21 mai 2016, mariusz sapinski a écrit :
> >    I'm trying to convert text from a text field:
> > to double (property double ekpu)
> You may want to use parseFloat().
>
> http://www.w3schools.com/jsref/jsref_parseFloat.asp
>
> Damien.
> _______________________________________________
> SailfishOS.org Devel mailing list
> To unsubscribe, please send a mail to
> devel-unsubscribe at lists.sailfishos.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20160522/4b9aedbb/attachment.html>


More information about the Devel mailing list