pythonpyqtpyqt5qtwebengineqtwebchannel

Warnings when instantiating QWebChannel object in javascript


I have a widget which creates a google maps instance using QWebChannel. When instantiating the QWebChannel within javascript several warnings appear:

Property 'accessibleName'' of object 'MapWindow' has no notify signal and is not constant, value updates in HTML will be broken!
Property 'accessibleDescription'' of object 'MapWindow' has no notify signal and is not constant, value updates in HTML will be broken!
Property 'layoutDirection'' of object 'MapWindow' has no notify signal and is not constant, value updates in HTML will be broken!
Property 'autoFillBackground'' of object 'MapWindow' has no notify signal and is not constant, value updates in HTML will be broken!
Property 'styleSheet'' of object 'MapWindow' has no notify signal and is not constant, value updates in HTML will be broken!
Property 'locale'' of object 'MapWindow' has no notify signal and is not constant, value updates in HTML will be broken!
Property 'windowFilePath'' of object 'MapWindow' has no notify signal and is not constant, value updates in HTML will be broken!
Property 'inputMethodHints'' of object 'MapWindow' has no notify signal and is not constant, value updates in HTML will be broken!
var backend = null;
new QWebChannel(qt.webChannelTransport, function(channel) {
    backend = channel.objects.backend;
    backend.getRef(function(ref) {
        backend.getCenter(function(center) {
            backend.getPoints(function(points){
                map = new google.maps.Map(document.getElementById('map'), {
                   center: center[0],
                   zoom: 10
                 });
                 ...
self.mapView = QWebEngineView()
self.webchannel = QWebChannel(self.mapView)
self.mapView.page().setWebChannel(self.webchannel)
self.webchannel.registerObject('backend', self)
current_dir = os.path.dirname(os.path.realpath(__file__))
filename = os.path.join(current_dir, '.\Resources\index.html')
self.mapView.load(QUrl.fromLocalFile(filename))

Solution

  • QWebChannel will analyze the q-properties of the registered object verifying that they have associated signals. In your case of the warning message I deduce that "self" is a QWidget so it has many q-properties that have no associated signals signaling the error.

    Given the above there are 2 solutions:

    QtCore.qInstallMessageHandler(lambda *args: None)
    
    class Backend(QObject):
        # getRef, getCenter, getPoints
    
    self.backend = Backend(self)
    self.webchannel.registerObject('backend', self.backend)