[SailfishDevel] string to double in QML?

Alexander Ladygin fake.ae at gmail.com
Mon May 23 09:06:22 UTC 2016


it's not C++, it's JavaScipt function, you can use it inside QML

onClicked: {

                 ekpu=parseFloat(ekField.text)



                 pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
             }

On Sun, May 22, 2016 at 5:17 AM, Peter Kovacs <leginee at gmail.com> wrote:

> 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
>
>
>
> _______________________________________________
> 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/20160523/2f75ae21/attachment.html>


More information about the Devel mailing list