How to use QWebElement?

  • I don't understand how this work because all examples didn't work for me. Here is simple example from the doc which also doesn't work :
    @#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 :

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.