I'm just starting out with javascript and Qt so bear with me
My issue is with the runJavaScript method. I can't seem to get the callback function to run with a returned value that's delayed. For example, the following prints None.
js = '''
function returnHello(){
var i = 0;
var wait = setInterval(function() { //arbitrary delay
i++
if(i>2){
return('hello')
}
}, 10);
}
returnHello();
'''
def test(a):
print(a)
mw.reviewer.web.page().runJavaScript(js, test)
I suspect it has something to do with how javascript runs asynchronously, and I tried playing around with javascript callback methods, but if there's any delay in returning values, the Qt python callback method always seems to accept the undefined default javascript return value.
I've been scouring the internet for answers, so any help would be great!