Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using WebChannel and WebEngine IPC to get access to QtObjects from HTML
Forum Updated to NodeBB v4.3 + New Features

Using WebChannel and WebEngine IPC to get access to QtObjects from HTML

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • dominatorD Offline
    dominatorD Offline
    dominator
    wrote on last edited by
    #1

    Hi all,

    I'm trying to establish a connection between the HTML and QtQuick Application. On the QML Side I create an QtObject and add it to the WebChannel

    QtObject{
            id: rotateID
            WebChannel.id: "rotateJS"
    
            function screenOrientation(value){
                //do something
            }
        }
    
    WebEngineView {
            id: webEngine
            WebChannel{
                   id: testobject
                   registeredObjects: [rotateID]
                   }
        }
    
    

    Inside the HTML I'm using the qwebchannel.js and try to call this function

    new QWebChannel(qt.webChannelTransport, function (channel) {
          channel.rotateJS.screenOrientation("portrait");
        });
    

    Unfortunately it seems that the communction via the WebEngine IPC doesn't work. Does anyone have experience with this?

    Best,
    Dominator

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      you can check if there are any javascript errors on the console.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • dominatorD Offline
        dominatorD Offline
        dominator
        wrote on last edited by
        #3

        I don't get any errors. I have no idea what else i can try

        1 Reply Last reply
        0
        • dominatorD Offline
          dominatorD Offline
          dominator
          wrote on last edited by
          #4

          I found the problem.

          You have to set the webChannel property of the WebEngineView

          WebEngineView {
                  id: webEngine
                 webChannel: testobject
                  
              }
          WebChannel{
                 id: testobject
                 registeredObjects: [rotateID]
              }
          
          
          1 Reply Last reply
          3

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved