I'd like extract the information
in the b
tag => 123456789
this is the HTML source :
<body>
<div>
<table>
<tbody>
<tr>
<td class="myclass">
<b>123456789</b>
</td>
</tr>
</tbody>
</table>
</div>
</body>
So, I tried this :
void My_Test_Dialog::on_pushButton_clicked()
{
QWebView *webview = new QWebView(parentWidget());
webview->load(QUrl("http://www.esesese.com"));
webview->show();
// get HTML element information
QWebElementCollection colls = webview->page()->mainFrame()->findAllElements("td.myclass b");
foreach(QWebElement elemento, colls)
{
ui->lineEdit_data->setText(elemento.toInnerXml());
}
}
I have a form with a Button(call update
) and a LineEdit
, so if I click on the update
button, the LineEdit
should set the text 123456789
automatically. But my code doesn't work. The Text of the LineEdit
remains empty.
I include this :
#include <QtWebKit>
#include <QtWebKitWidgets/QWebFrame>
#include <QWebView>
QT file.pro is :
QT += core gui
QT += network
QT += webkit
QT += webkitwidgets