0

How can we print out what an webview contains? i tried something like :

view.page().currentFrame().toPlainText()

but it didn't work

PS: my webview contains an evaluation of a javascript function , so i suppose toHtml() won't do the job any suggestion?

  • How do you mean print out? Are you after plain text, rich text, a screen grab? :) – sam-w Apr 25 '12 at 08:39
  • Actually i wanted the webview to show a result of an execution of a javascript function but i figured lately that this cannot be done unless the function is evaluated in a webpage. correct me if i'm wrong –  Apr 26 '12 at 10:27
  • Not sure I completely understand what you're after: do you want to take the numerical/textual output of a js function and use it in your Qt/C++ application, or are you trying to display a webpage with javascript-generated elements? – sam-w Apr 26 '12 at 14:35
  • I rather want to display a webpage with javascript-generated elements.also i couldn't figure out what event or function should be called and what parameters should i pass to the function to have the expected results in my webview , i tried with some developement tools of browsers like Firebug but i couldn't find how it works ,can you help with an static exemple i heard that i can do that by adding "debugger;" into my javascript code is that true , how could i do this ?thx –  Apr 26 '12 at 21:15

1 Answers1

0

QtWebKit will display javascript-generated webpages exactly the same as it will display any other webpage (though you can disable js through QWebSettings). I assume then, that you want the webpage to generate elements based on requests from the C++ application.

If that's the case, you want QWebFrame::evaluateJavaScript (as previously stated in this previous question: Qt4: How to call JavaScript functions in a page from C++ via QtWebkit?).

More generally, you might find this useful.

Community
  • 1
  • 1
sam-w
  • 7,478
  • 1
  • 47
  • 77