Gotta love that hack!
So to go from python to javascript you use pyqt5 to invoke runjavascript to send a json object to your own javascript routine preloaded in the page.
Then to go the other way, javascript just changes the document title to add a message and a Qt signal titleChanged() is fired automatically which tells the python side to run a javascript to get the result from the document title tag resetting it back to normal. And since the document title is for informational purposes and not actually shown, everything just works!
And this can work for any number of different webpages each with its own document title.
Absolutely wonderful! No pipes, no shared memory, no extra signals, no QWebChannel, just a little extra javascript to read and manipulate the document title.
Qt should pay you for this idea and then create an extra signal tied to an always *non-displayed* tag such as a qt:message tag stored in head or even a standard comment tag in head.
Nicely done!
|