1

I have this code:

class TestThread : public QThread
{
public:
    void run()
    {
        QFile file("test.html");
        file.open(QIODevice::ReadOnly);
        QWebPage page;
        page.mainFrame()->setHtml(file.readAll());
        qDebug() << page.mainFrame()->toHtml();
        qDebug() << "\n\n\n\n";
    }
};

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    for(int i = 0; i < 2; ++i)
    {
        TestThread thread;
        thread.start();
        thread.wait();
    }
    return a.exec();
}

And output:

"<html><head>
    <title>My page</title>
  </head>
  <body>
        My content

</body></html>" 





"<html><head></head><body><html>
  <head>
    <title>My page</title>
  </head>
  <body>
        My content
  </body>
</html></body></html>"

In the second pass, there are too many tags. What is workaround? Or where is my mistake?

Troubadour
  • 13,334
  • 2
  • 38
  • 57
brainstream
  • 451
  • 4
  • 17

1 Answers1

0

I had the issue in the Linux OS. In Windows I got the message "Widgets must be created in GUI thread". But the content in the QWebPage is correct. So, I will not be used QWebPage for my task.

brainstream
  • 451
  • 4
  • 17