Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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))
like image 864
Evan Brittain Avatar asked Oct 20 '25 01:10

Evan Brittain


1 Answers

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:

  • Silence the error message by disabling the qInstallMessageHandler:
QtCore.qInstallMessageHandler(lambda *args: None)
  • Do not use "self" as a backend but a QObject
class Backend(QObject):
    # getRef, getCenter, getPoints
self.backend = Backend(self)
self.webchannel.registerObject('backend', self.backend)
like image 130
eyllanesc Avatar answered Oct 21 '25 15:10

eyllanesc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!