Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Running QWebPage in a QThread



  • I tried to run QWebPage in a thread and I'm getting this warning:

    QObject: Cannot create children for a parent that is in a different thread.

    It's really simple the code:

    void Thread::run() {
        auto page = new QWebPage;
        page->mainFrame()->load(QNetworkRequest(QUrl("http://google.com")));
    }

  • Lifetime Qt Champion

    It is not allowed to use UI related Qt classes in a different thread. They all must be used in the same thread in which the event loop is executed.
    Why do you want to use QWebPage in a different thread?
    As far as I know the UI of your application should not block while the web page is loaded.


Log in to reply