Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Sending external events to QtWebView components
Forum Updated to NodeBB v4.3 + New Features

Sending external events to QtWebView components

Scheduled Pinned Locked Moved Qt WebKit
4 Posts 3 Posters 1.9k 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.
  • J Offline
    J Offline
    jaya
    wrote on last edited by
    #1

    All,
    Here is my requirement.

    1. My Qt WebKit applictaion loads the html page which has Html Buttons and javascript.
    2. An external event [comes from different process via sockets] should be captured and sent to this QtWebkit html page. Those events [JSON format] will be processed through Javascript and action will be taken in the html flow.
      Will it be possible using in QT? If so what is the approach [ classes i should look into]?

    And the screen display is controlled by different process and and user inputs [button clicks] will not be available to Qt webview directly. But they can be available to [x,y] coordinate to Qt application. If so, how these clicks can be processed inside the application.

    Please guide me the approach.

    Inotially i though of using Node.JS with websockets support where the external events [JSON] will be given to html loaded through QT. Unfortunately Node.JS and websockets support is not available, so i have do find different approach to receive the events from various processes.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kdkdkd
      wrote on last edited by
      #2

      You can capture data from socket by using "qtcpsocket":http://qt-project.org/doc/qt-5.1/qtnetwork/qtcpsocket.html class.

      There are two ways to interact with html page, which I know - sending events to it and executing javascript. Sending events approach suffers from scroll problem. It is desribed on that "page":http://stackoverflow.com/questions/2655414/qt-force-qwebview-to-click-on-a-web-element-even-one-not-visible-on-the-window in details. Executing javascript is a bit easier. For example, here is clicking on link function:

      @el.evaluateJavaScript("this.click()")@

      where el is QWebElement, which may be found by css selector.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jaya
        wrote on last edited by
        #3

        Thanks,
        My further question is, if i have html page loaded through QtWebView
        and the html has something like this in javascript.

        var exampleSocket = new WebSocket("ws://www.example.com/socketserver", "protocolOne");

        Can Qtwebkit latest supports 'Websocket' and "ws://"?

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rahul Das
          wrote on last edited by
          #4

          Yes, Webkit supports web socket. If you are looking for examples : "start from this":https://gitorious.org/qtwebsocket

          EDIT : I think the above example does not support secure ws. Otherwise works fine. The Qt5 & Qt4 Port are slightly different.

          You can make use of the Bridge APIs, so that your c++ objects can be exposed to JS environment.


          Declaration of (Platform) independence.

          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