Search code examples
qtqtwebkitqtscript

QWebView find text inside invisible elements


In my Qt project I'm using the QWebView to load my html table data.

I'm using the findText function to find text in the html page.

But, I can't find invisible text...

HTML sample :

<table>

  <tr>
    <td> hello </td>
  </tr>

  <!-- invisible data -->
  <tr style="display:none">

    <!-- I want to find this value -->
    <td> hey </td>

  </tr>

</table>

Is there a way to find invisible text elements via Qt?

I know that I can evaluate JavaScript function for that..

But still I'm looking for some Qt solution?

Thanks in advance.


Solution

  • You can use QWebFrame::findAllElements() function which will perform elements look up by CSS selector and return all found elements as QWebElementCollection regardless of their visibility. From that list you can find the QWebElement that correspond to your searching criterion.