Tutorial :How can I access the data from javascript by Qt?



Question:

I used webview to show the webpage,

view->setUrl(QUrl("C:\\Qt\\2010.07\\qt\\serbest\\googleSearch.htm"));  

in the HTML code I put some ajax code googleSearch. After I execute the program, the webview runs and there are results (pages links).

When I clicked any of the links they do not open. So what do I do to open the links I clicked?

How can I access the title of the links from the result of javascript in Qt?


Solution:1

"C:\Qt\2010.07\qt\serbest\googleSearch.htm"  

That's not a URL, it's a Windows pathname. Also, it has troublesome unescaped backslashes: \201 is a string literal escape for the control character U+0081 in many languages (including JavaScript as per your tags, though the snippet does not appear to actually be JavaScript).

The URL form of that filename would look something like:

"file:///C|/Qt/2010.07/qt/serbest/googleSearch.htm"  

You can convert a filename into a URL using fromLocalFile().


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »