[ create a new paste ] login | about

Link: http://codepad.org/3AngioSd    [ raw code | fork ]

Python, pasted on Dec 23:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtQml import *
myEngine=QJSEngine()

three = myEngine.evaluate("1 + 2")
print(three.toNumber())# works well 

myEngine.globalObject().setProperty("myNumber", QJSValue(123))
myNumberPlusOne = myEngine.evaluate("myNumber + 1");
print(myNumberPlusOne.toNumber())# return the wrong value !!!!!!

fun = myEngine.evaluate("(function(a, b) { return a + b; })");

args =[QJSValue(1), QJSValue(2)]#it would be better if we could simply write this as args =[1,2],we cannot do this right now ,bad !!!!
threeAgain = fun.call( args)
    
    
print(threeAgain.toString())# return the wrong value !!!!!!


Create a new paste based on this one


Comments: