QML WebChannel - "value updates in HTML will be broken"



  • After a bit of work, I've got WebChannel working from my QML:

    import QtQuick 2.7
    import QtQuick.Window 2.2
    import MyLibrary 1.0
    
    Window {
        width: 1280
        minimumWidth: 1024
    
        height: 960
        minimumHeight: 240
    
        WebEngineView {
            webChannel: myWebChannel
    
            anchors.fill: parent
        }
    
        WebChannel {
            id: myWebChannel
            registeredObjects: [myLibraryObject]
        }
    
        MyLibraryObject {
            id: myLibraryObject
            WebChannel.id: "myLibaryObject"
        }
    }
    

    The HTML:

    <head>
        <script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
        <script type="text/javascript" src="qrc:///js/modules/myLibrary.js"></script>
    </head>
    

    And the Javascript:

    console.log("myLibrary.js");
    
    window.onload = function() {
        new QWebChannel(qt.webChannelTransport, function (channel) {
            var myLibraryObject = channel.objects.myLibraryObject;
    
            console.log(myLibraryObject.label);
        });
    }
    

    When I run my application, the debug output is full of "Property 'X' of object 'QQuickItem' has no notify signal and is not constant, value updates in HTML will be broken!"

    It refers not only to my custom MyLibraryObject, but also QQuick objects lik QQuickItem and QQuickRectangle.

    I'm also seeing a number of "Don't know how to handle '', use qRegisterMetaType to register it."

    How is this all fixed?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.