[Interest] QWebview signals with dynamic web pages

Murphy, Sean M. sean.murphy at gd-ais.com
Mon Mar 5 15:39:36 CET 2012

> > I'm trying to read an 8-channel temperature sensor device that outputs its
> > data via a web interface.  Viewing the device's web page via a normal web
> > browser, or via QWebView::load(), I can see the temperatures correctly.  The
> > temperature values are "live" in that they automatically update about once a
> > second, without the user having to manually reload/refresh the browser.  My
> > HTML skills are pretty minimal, so I'm not sure what magic it uses to update
> > those parameters, but I don't see any sort of <meta http- equiv="refresh"
> > content="1"> tag.
> That might be some AJAX-y magic I guess? :) There might be some JS
> code that is sending some request and updating only a particular DOM
> element?

That certainly seems to be the behavior, and that's where it gets beyond my level of web knowledge, might be time to start learning that - it seems this whole web fad might be here to stay!
> Is it possible for you to alter the web pages code? If so, you could
> probably use the webkit-bridge concept where the page (via some
> modified JS code) calls a Qt slot on each refresh.

I can't alter the web page's code, it's coming from a vendor's device that has an embedded webserver installed.  So closed architecture, closed source, etc...

> Or if thats not possible, how about inspecting the DOM and finding out
> the value of the required element? I guess you're already doing that
> on page load, but you probably don't have to refresh the page from
> outside as the page is doing that itself. If you can find the refresh
> time that the page is using, you could use the same refresh freq for
> parsing the DOM tree once a page load completes. Would that work?

That's sort of what I'm doing now.  My initial code had a slot that would parse the HTML for the values I'm looking for.  I connected that slot to the QWebView's loadFinished() signal, which worked ONCE; on the initial connection to the web server only.  So what I've now done is created a QTimer running every 100ms that keeps calling loadFinished(), which keeps reparsing the HTML, and this works.

So the raw HTML is changing - I'm just surprised that Qt doesn't seem to have any signals that get triggered off from this...


More information about the Interest mailing list