Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I haven't actually done this, but I think you <em>may</em> be able to achieve your solution using <code>QNetworkAccessManager</code>.</p> <p>You can get the QNetworkAccessManager from your QWebPage using the <a href="http://doc.trolltech.com/4.5/qwebpage.html#networkAccessManager" rel="noreferrer">networkAccessManager()</a> function. QNetworkAccessManager has a signal <a href="http://doc.trolltech.com/4.5/qnetworkaccessmanager.html#finished" rel="noreferrer">finished ( QNetworkReply * reply )</a> which is fired whenever a file is requested by the QWebPage instance.</p> <p>The <code>finished</code> signal gives you a QNetworkReply instance, from which you can get a copy of the original request made, in order to identify the request.</p> <p>So, create a slot to attach to the <code>finished</code> signal, use the passed-in QNetworkReply's methods to figure out which file has just finished downloading and if it's your Ajax request, do whatever processing you need to do.</p> <p>My only caveat is that I've never done this before, so I'm not 100% sure that it would work.</p> <p>Another alternative might be to use QWebFrame's methods to insert objects into the page's object model and also insert some JavaScript which then notifies your object when the Ajax request is complete. This is a slightly hackier way of doing it, but should definitely work.</p> <p>EDIT:</p> <p>The second option seems better to me. The workflow is as follows:</p> <p>Attach a slot to the QWebFrame::javascriptWindowObjectCleared() signal. At this point, call QWebFrame::evaluateJavascript() to add code similar to the following: window.onload = function() { // page has fully loaded }</p> <p>Put whatever code you need in that function. You might want to add a QObject to the page via QWebFrame::addToJavaScriptWindowObject() and then call a function on that object. This code will only execute when the page is fully loaded.</p> <p>Hopefully this answers the question!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COYour line of thinking is good. It's what I'm doing now and it has been working till now. Now, I have a problem because I call some js function after receiving finished() signal and it has no effect although it should. When I call the same js function manually using a button on a form with a view of my page it works as it should - it sends a post asking about additional data. I guess waiting only on finished() signal of QNAM is not enough as after receiving data QWebFrame has to modify DOM and maybe do other things before it's ready to handle js calls. Please update your answer to reflect this.
      singulars
    2. COCan you give me some more information about exactly what you're trying to achieve? As far as I understand it, it's this: 1) You load a page (via QWebView->load() or some other method) 2) When the page content (the HTML) has been received, QNAM fires the finished() signal 3) When the whole page - including JS files, CSS and images - has finished loading, the QWebPage object fires the loadFinished() signal 4) At some later point, extra data is loaded via Ajax And you want to know when #4 has happened? Please explain further and I may be able to answer your question fully.
      singulars
    3. COad 1. Not exactly. I'm using QWebFrame::load as I don't need rendering phase at all. Currently however, I **am** using QWebView::setPage to view how the page looks like but this is only for debugging purpose. ad 2. I'm not interested in html alone so I don't use this signal here. ad 3. Yes. ad 4. Yes. The moment of this ajax call is strictly defined; it happens in the moment user clicks on part of a data row. Here is my problem. I'm calling the same js function with evaluateJavaScript and nothing happens; there is no network request being send (I'm monitoring all requests QNAM is sending). TBC
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload