View Single Post
Old 06-18-2019, 12:00 PM   #18
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,893
Karma: 6120478
Join Date: Nov 2009
Device: many
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!
KevinH is offline   Reply With Quote