#include <QApplication>
#include <QDebug>
#include <QWebPage>
#include <QWebFrame>
#include <QWebElement>
int main(int argc, char *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();
}
#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();
}
To copy to clipboard, switch view to plain text mode
Output is :
This example is from oficial doc so why this always empty and when i use other exaples it is empty too.
Bookmarks