Based on QT QWebEnginePage::setWebChannel() transport object and Qt: Cannot invoke shared object methods/properties from javascript I tried to make a small demo to test the
Faced same issue... Reading doc's carefully gave me the answer. The answer is that communication between Qt and JS in Qt5 is asynchronous. You have to provide callback function which will be called after method completed and result value received.
Instead of calling
var n = theQtObj.getInt(X);
PrintLog(" back in js with n="+n);
you can call at as
theQtObj.getInt(X, function(n) {
PrintLog(" back in js with n="+n);
});