Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. Need to signal/trigger/call/whatever from WebEngineView content...
Forum Updated to NodeBB v4.3 + New Features

Need to signal/trigger/call/whatever from WebEngineView content...

Scheduled Pinned Locked Moved Unsolved QtWebEngine
7 Posts 2 Posters 2.6k Views 1 Watching
  • 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.
  • V Offline
    V Offline
    VRHans
    wrote on last edited by
    #1

    ...into my Qml code.

    I've been reading on this and was quite surprised to find that window.postMessage doesn't exist, the Qt JavaScript bridge no longer works, and that WebChannel solutions appear to require that the page (which I do not control) must include a bunch of Qt specific JavaScript.

    Is there a way for the HTML/JS content of a page viewed in a WebEngineView to signal my Qml code?

    If I'm signalled I can run an eval against the page content and pull the data I need - but I can't find a way to trigger this except when a pageload completed event happens (and by this time it's too late.)

    Suggestions? Thanks!

    V raven-worxR 2 Replies Last reply
    0
    • V VRHans

      ...into my Qml code.

      I've been reading on this and was quite surprised to find that window.postMessage doesn't exist, the Qt JavaScript bridge no longer works, and that WebChannel solutions appear to require that the page (which I do not control) must include a bunch of Qt specific JavaScript.

      Is there a way for the HTML/JS content of a page viewed in a WebEngineView to signal my Qml code?

      If I'm signalled I can run an eval against the page content and pull the data I need - but I can't find a way to trigger this except when a pageload completed event happens (and by this time it's too late.)

      Suggestions? Thanks!

      V Offline
      V Offline
      VRHans
      wrote on last edited by
      #2

      Nothing?

      Qt has a webengine that it cannot signal itself with?

      1 Reply Last reply
      0
      • V VRHans

        ...into my Qml code.

        I've been reading on this and was quite surprised to find that window.postMessage doesn't exist, the Qt JavaScript bridge no longer works, and that WebChannel solutions appear to require that the page (which I do not control) must include a bunch of Qt specific JavaScript.

        Is there a way for the HTML/JS content of a page viewed in a WebEngineView to signal my Qml code?

        If I'm signalled I can run an eval against the page content and pull the data I need - but I can't find a way to trigger this except when a pageload completed event happens (and by this time it's too late.)

        Suggestions? Thanks!

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @VRHans said in Need to signal/trigger/call/whatever from WebEngineView content...:

        I've been reading on this and was quite surprised to find that window.postMessage doesn't exist, the Qt JavaScript bridge no longer works, and that WebChannel solutions appear to require that the page (which I do not control) must include a bunch of Qt specific JavaScript.

        even the HTML source isn't under your control, you can still inject JavaScript (and thus QtWebChannel) into the page.
        See here for example.

        --- 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

        V 1 Reply Last reply
        0
        • raven-worxR raven-worx

          @VRHans said in Need to signal/trigger/call/whatever from WebEngineView content...:

          I've been reading on this and was quite surprised to find that window.postMessage doesn't exist, the Qt JavaScript bridge no longer works, and that WebChannel solutions appear to require that the page (which I do not control) must include a bunch of Qt specific JavaScript.

          even the HTML source isn't under your control, you can still inject JavaScript (and thus QtWebChannel) into the page.
          See here for example.

          V Offline
          V Offline
          VRHans
          wrote on last edited by
          #4

          @raven-worx

          Is this considered a moderately safe (as in 'not completely fragile') approach?

          In other words, I haven't evaluated the code that constitutes the JS side of QtWebChannel, so I'm wary of namespace collisions. Luckily I don't need to be triggered early on in the page's lifecycle, so I'm not likely to suffer from a race condition.

          Thanks very much for the suggestion - I'll try it today :)

          Hans
          
          V 1 Reply Last reply
          0
          • V VRHans

            @raven-worx

            Is this considered a moderately safe (as in 'not completely fragile') approach?

            In other words, I haven't evaluated the code that constitutes the JS side of QtWebChannel, so I'm wary of namespace collisions. Luckily I don't need to be triggered early on in the page's lifecycle, so I'm not likely to suffer from a race condition.

            Thanks very much for the suggestion - I'll try it today :)

            Hans
            
            V Offline
            V Offline
            VRHans
            wrote on last edited by
            #5

            @raven-worx One question though - my webengine view is created and managed in my UI's Qml code - is this same approach available via Qml (creating a script, adding it to the document creation portion of the lifecycle, et cetera)?

            I can muddy my architecture a bit if I need to do this on the C++ side, but it would be better if I did not...

            raven-worxR 1 Reply Last reply
            0
            • V VRHans

              @raven-worx One question though - my webengine view is created and managed in my UI's Qml code - is this same approach available via Qml (creating a script, adding it to the document creation portion of the lifecycle, et cetera)?

              I can muddy my architecture a bit if I need to do this on the C++ side, but it would be better if I did not...

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @VRHans
              The QML WebEngineView supports also profiles.
              The WebEngineProfile QML Type instantiates a QQuickWebEngineProfile type.

              For interaction with QML elements from C++ see this.

              --- 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

              V 1 Reply Last reply
              0
              • raven-worxR raven-worx

                @VRHans
                The QML WebEngineView supports also profiles.
                The WebEngineProfile QML Type instantiates a QQuickWebEngineProfile type.

                For interaction with QML elements from C++ see this.

                V Offline
                V Offline
                VRHans
                wrote on last edited by
                #7

                @raven-worx Thx, I will get cracking on this. Much appreciated.

                1 Reply Last reply
                0

                • Login

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