[PyQt] Empty string converted to 0.0 using pyqtSlot

Alexander Rössler alexander at roessler.systems
Fri Sep 21 21:59:28 BST 2018


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 at 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 at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180921/cd13eb6a/attachment.html>


More information about the PyQt mailing list