orkto
23rd December 2014, 16:50
#include <QApplication>
#include <QDebug>
#include <QWebPage>
#include <QWebFrame>
#include <QWebElement>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWebPage frame;
frame.mainFrame()->setHtml("<html><body><p>First Paragraph</p><p>Second Paragraph</p></body></html>");
QWebElement doc = frame.mainFrame()->documentElement();
QWebElement body = doc.firstChild();
qDebug() << body.toPlainText();
QWebElement firstParagraph = body.firstChild();
qDebug() << firstParagraph.toPlainText();
QWebElement secondParagraph = firstParagraph.nextSibling();
qDebug() << secondParagraph.toPlainText();
return a.exec();
}
Output is :
http://i.stack.imgur.com/AwrXq.png
This example is from oficial doc so why this always empty and when i use other exaples it is empty too.
#include <QDebug>
#include <QWebPage>
#include <QWebFrame>
#include <QWebElement>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWebPage frame;
frame.mainFrame()->setHtml("<html><body><p>First Paragraph</p><p>Second Paragraph</p></body></html>");
QWebElement doc = frame.mainFrame()->documentElement();
QWebElement body = doc.firstChild();
qDebug() << body.toPlainText();
QWebElement firstParagraph = body.firstChild();
qDebug() << firstParagraph.toPlainText();
QWebElement secondParagraph = firstParagraph.nextSibling();
qDebug() << secondParagraph.toPlainText();
return a.exec();
}
Output is :
http://i.stack.imgur.com/AwrXq.png
This example is from oficial doc so why this always empty and when i use other exaples it is empty too.