I have a Qt application that launches Webviews using QWebChannel .
In these views, I have JavaScript that does some things to fit / resize a window depending on the screen size. The screen object must provide such information. ( screen document )
But in my QWebEnginePage display object is empty during the whole loading process.
If I put a listener on a button to get screen.height somewhere on the page, now it works.
//js local file called in html head //screen = {} document.addEventListener("load", function(event) { //screen = {} new QWebChannel(qt.webChannelTransport, function(channel) { //screen = {} //stuff channel.object.myClass.show(function(res){ //Qt function that calls the show() method of the QWebEngineView //screen = {} }); }); document.getElementById("myBtn").addEventListener("click", function(){ console.log("height:" + screen.height); // screen: 1440 }); });
So my question is: how can I access the screen values ββat some point in my JavaScript?
source share