Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Running QWebPage in a QThread
QtWS25 Last Chance

Running QWebPage in a QThread

Scheduled Pinned Locked Moved Unsolved General and Desktop
qthreadqwebpage
2 Posts 2 Posters 975 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yodusow bardon
    wrote on 6 Dec 2015, 11:41 last edited by yodusow bardon 12 Jun 2015, 11:41
    #1

    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")));
    }
    
    1 Reply Last reply
    0
    • J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 7 Dec 2015, 05:50 last edited by
      #2

      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.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      6 Dec 2015, 11:41

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved