You could probably write a JavaScript snippet that returns the values you need and run it via http://doc.qt.io/qt-5/qwebenginepage...unJavaScript-1
Cheers,
_
You could probably write a JavaScript snippet that returns the values you need and run it via http://doc.qt.io/qt-5/qwebenginepage...unJavaScript-1
Cheers,
_
I'm not sure but maybe it is a matter of wrong syntax. I was using QWebElement to get Html elements and it worked but I used much simpler expressions. You have to try. I don't remember but I probably had problems with using # sign.
There is also QTextDocument, you can find element in QString with regular expressions and then put it into QTextDocument and use method toPlainText().
i believe thats not possible because runjavascript function returns void...
i believe that get the text can be accomplished by using QWebEnginePage selectedText() this function returns a QString of the current selected text, next step is to virtually select the text using javascript and iterate over all table cells but i'm stuck in the part of set the cell value as selected...any ideas?
The documentation says "functor or lambda" so it depends a bit if you have C++11 available for lambda.
Qt Code:
// your callback code });To copy to clipboard, switch view to plain text mode
As a functor
Qt Code:
struct ScriptCallback { // your callback code } }; runJavaScript(script, ScriptCallback());To copy to clipboard, switch view to plain text mode
Cheers,
_
danalex07 (5th February 2016)
thanks to anda_skoa i got this far...
Qt Code:
webFrame->runJavaScript("function myFunction() {var myvar=document.querySelector('#GridView1 td:nth-child(3)');return myvar;} myFunction();", qDebug()<<result; });To copy to clipboard, switch view to plain text mode
but i'm stuck know in js because it doesn't return the cell value i'm pointing to with the querySelector...maybe wrong syntaxis?
Have you tried with a simple expression first?
E.g. a a fix return without a function, then within a function?
Cheers,
_
danalex07 (5th February 2016)
yes simple function like "return 3.4" or "function myFunction() {return 3.4;} myFunction();" works fine, but i can't just find a javascript functions that saves table cell value
<table id="GridView1">
<tr>
<td>104534</td>
<td>04/04/2014</td>
<td>DM70F36L23CM</td>
</tr>
</table>
Ok finally i got it...
for anyone interested in the code
Qt Code:
webFrame->runJavaScript("function myFunction() {" "var Row = document.getElementById('GridView1');var Cells = Row.getElementsByTagName('td');" "return Cells[0].innerText;} myFunction();", qDebug()<<result.toString(); });To copy to clipboard, switch view to plain text mode
Bookmarks