Getting data from runJavaScript()
-
Hello,
I'm using a QWebEngine.page().runJavaScript() to read a js string in order to display a js into a mainWindow and a plugin. I need to access to the js variable in my python script to show data. How can i access to the js variable ?
For example i would like to get the stage variable in this script : -
@MHaqui
Hello and welcome.For the future please paste code, not a screenshot, as it helps people answer questions.
To retrieve data from JS script have a look at the techniques in QtWebEngine - synchronously execute JavaScript to read function result. Basically they are using a
QVariant
as an argument to a lambda call passed torunJavaScript()
.You'll have to figure how to for Python. For one thing it may depend on whether you are PyQt or PySide which you don't say. See also https://forum.qt.io/topic/100303/qtwebenginepage-runjavascript. And the complicated https://stackoverflow.com/questions/61473152/how-to-get-return-value-from-pyqts-qwebenginepage-runjavascript.
@eyllanesc may know the current state of play with Python/PyQt/PySide....