-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support conversion of JS Boolean variables to Python bool #22
Comments
The translator doesn't handle Boolean objects, just the true/false constants. BTW: why would you use Boolean(true)? |
Just simplifying with |
It does but apparently the javascript engine doesn't treat new Boolean() as a boolean |
Specifically it seems that instead of QVariant with bool you get some other (I don't know javascript engine types to be sure) type. |
Indeed - thank you for your help! I've replaced: var bar = new Boolean(baz); with: var bar = baz ? true : false; and all is well! |
While in general, you should use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean Reopening. Maybe we can get around to implement that at some point. |
I have a problem where a JavaScript variable with a boolean value is not being passed to the Python function correctly, and I end up with an empty Python dict.
qmlexperiment.py contains:
qml contains:
output:
Am I doing something wrong, or should the function be being passed a Python boolean?
If
bar
is replaced withtrue
in the call args, then the Python function is correctly passed in 'True':The text was updated successfully, but these errors were encountered: