[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Empty string converted to 0.0 using pyqtSlot
From:       Alexander_Rössler <alexander () roessler ! systems>
Date:       2018-09-21 20:59:28
Message-ID: 1537563469.local-31caad61-ecaf-v1.4.2-f587b7b7 () getmailspring ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Because "" is falsy and converted to Double 0.0 in JS. If you set for example "1" it \
probably also will work, since JS knows how to convert it to a number.

On Sep 17 2018, at 8:44 pm, Kálmán Viktor <viktorvector@gmail.com> wrote:
> 
> Hello,
> 
> this code produces the following output
> 
> Python snippet
> @pyqtSlot(float)
> def xy(self, amount):
> 
> print("am", amount)
> 
> 
> QML snippet
> print(amountInput.text, amountInput.text === "")
> controller.xy(amountInput.text)
> 
> 
> Output
> qml: true
> am 0.0
> 
> 
> Is this intentional? If I use any other string than "" I get (I think the correct) \
> nan. I'm using PyQt5==5.11.2 
> _______________________________________________
> PyQt mailing list PyQt@riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 


[Attachment #5 (text/html)]

<div>Because "" is falsy and converted to Double 0.0 in JS. If you set for example \
"1" it probably also will work, since JS knows how to convert it to a \
number.</div><br><div class="gmail_quote_attribution">On Sep 17 2018, at 8:44 pm, \
Kálmán Viktor &lt;viktorvector@gmail.com&gt; \
wrote:</div><blockquote><br><div><div><div><div><div><div><div><div><div><div>Hello,</div><div><br></div><div>this \
code produces the following output</div><div><br></div><div>Python \
snippet</div><div>@pyqtSlot(float)</div><div><div>def xy(self, \
amount):</div></div><div><div>&nbsp; &nbsp; print("am", \
amount)</div></div><div><br></div><div>QML snippet</div><div>print(amountInput.text, \
amountInput.text === \
"")&nbsp;</div><div><div>controller.xy(amountInput.text)</div></div><div><br></div><div>Output</div><div><div>qml:&nbsp; \
true</div><div>am 0.0</div></div><div><br></div><div>Is this&nbsp;intentional? If I \
use any other string than "" I get (I think the correct) nan. I'm \
using&nbsp;PyQt5==5.11.2</div><div><br></div></div></div></div></div></div></div></div></div><div>_______________________________________________</div><div>PyQt \
mailing list PyQt@riverbankcomputing.com</div><div>https://www.riverbankcomputing.com/mailman/listinfo/pyqt</div></div></blockquote>



[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic