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. Finding the cordinates in html page using qt
QtWS25 Last Chance

Finding the cordinates in html page using qt

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 2.5k 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.
  • S Offline
    S Offline
    sarahjohn
    wrote on last edited by
    #1

    Hi,
    I am trying to give mouse events over network to a qt browser. In browser i have a socket receving the events .I get a coordinate to click with. I am posting the event to the webpage using
    QApplication::sendEvent( view, &releaseEvent );
    My Problem is
    I need to know the coordinates of icons anad images in html webpage to correctly click on that.
    How can I correctly get the cordinates of icons and all in html webpage be known from qt side.

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

      QWebElement has a geometry() method which returns the geometry inside it's parent frame.
      You need to handle and amp the rect upwards until you reach the mainFrame. QWebFrame also provides such a method.
      Will probably bit of a pain doing this.

      Maybe it's way easier to "simulate":http://stackoverflow.com/a/6158050 a mouse click event inside javascript directly.

      If your current design is based on QWebElement API thats not a problem. Since the "QtWebkit-Bridging":http://qt-project.org/doc/qt-4.8/qtwebkit-bridge.html takes care of converting a QWebElement object to a Javascript-DOMNode implicitly.

      E.g. you can send a signal from Qt - with the QWebElement as an parameter - and catch the signal in javascript.

      --- 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
      • T Offline
        T Offline
        trusktr
        wrote on last edited by
        #3

        [quote author="raven-worx" date="1389796344"]QWebElement has a geometry() method which returns the geometry inside it's parent frame.
        You need to handle and amp the rect upwards until you reach the mainFrame. QWebFrame also provides such a method.
        Will probably bit of a pain doing this.

        Maybe it's way easier to "simulate":http://stackoverflow.com/a/6158050 a mouse click event inside javascript directly.

        If your current design is based on QWebElement API thats not a problem. Since the "QtWebkit-Bridging":http://qt-project.org/doc/qt-4.8/qtwebkit-bridge.html takes care of converting a QWebElement object to a Javascript-DOMNode implicitly.

        E.g. you can send a signal from Qt - with the QWebElement as an parameter - and catch the signal in javascript.[/quote]

        Are you talking about catching the signal in the JavaScript of the "web page" in question? If you can add your own JavaScript to some arbitrary web page (e.g. bankofamerica.com) through the Qt browser, then you can easily set up a communication channel assuming the Qt web stuff allows you to connect to a domain other than the page's domain (e.g. your server instead of bankofamerica.com).

        That possible?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sarahjohn
          wrote on last edited by
          #4

          Rather than catching from html javascript,my objective is to click an image in html page from qtbrowser itself.For that I need to get the coordinates of the image in the html page.Is there any method to find the coordinates of the image in the webpage to click on it. How can i get the coordinates of the elements in webpage from qt side?
          I will try with QWebElement

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

            [quote author="sarahjohn" date="1389849755"]Rather than catching from html javascript,my objective is to click an image in html page from qtbrowser itself.[/quote]
            yes a click is more or less a mouse-press event right? So how do you react on mouse clicks anyway on your image elements? This done anyway on HTML/JavaScript right?

            [quote author="trusktr" date="1389816796"]
            Are you talking about catching the signal in the JavaScript of the "web page" in question? If you can add your own JavaScript to some arbitrary web page (e.g. bankofamerica.com) through the Qt browser, then you can easily set up a communication channel assuming the Qt web stuff allows you to connect to a domain other than the page's domain (e.g. your server instead of bankofamerica.com).[/quote]
            You can inject your Qt stuff into the loaded webpage's HTML. Thus making your Qt object available in the javascript enginge. This happens after the page has loaded.
            I don't know what you meant by connection to another channel?

            --- 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
            • S Offline
              S Offline
              sarahjohn
              wrote on last edited by
              #6

              yes click events are handled in javascript.I need only to internally click on the icon with the coordinates.How can I know the correct coordinates?

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

                as i already said:

                handle your way upwards with QWebElement/QWebFrame API

                simulate a javascript mouse event on the image element

                --- 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
                • S Offline
                  S Offline
                  sarahjohn
                  wrote on last edited by
                  #8

                  thank you raven-worx.It worked as you said.

                  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