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")));
    }

  • Moderators

    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
 

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