Proper way to add WebChannel to QML WebEngineView



  • I do not see any examples on how to configure a WebChannel from QML. Here is what I have tried thus far:

     Item {
                id: dummy
            }
            WebChannel {
                id:wc
                registeredObjects: dummy
    
            }
    
            WebEngineView {
                id: wv
                objectName: "webView"
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.top: testArea.bottom
                anchors.bottom: parent.bottom
                url: initialUrl
                webChannel: wc
            }
    

    The runtime error here is:
    Cannot register object "dummy" ( QQuickItem(0x113fdd0) ) without attached WebChannel.id property. Did you forget to set it?

    Can someone please tell me what I am doing wrong. Thanks

    -David



  • Sorry for the hasty post.
    A quick search on this forum told me what I needed to know.


  • Lifetime Qt Champion

    Hi,

    Glad you found out ! Can you share your discovery so other people may find it more easily ?



  • This link got me a little further. But think there should be a complete example as part of Qt/Examples


Log in to reply
 

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