title: Needing a working example on how to use QThreadPool
body: <p>I want to use multiThreading webkit with <code>QThreadPool</code></p>
  
  <p>My code is:</p>
  
  <p><strong>webkitrunnable.cpp:</strong></p>
  
  <pre><code>webkitRunnable::webkitRunnable(QUrl inputURL) : url(inputURL)
  {
      init();
  }
  
  void webkitRunnable::run()
  {
      qDebug() &lt;&lt; "run ...";
      qDebug() &lt;&lt; "webkit runnable --&gt; " &lt;&lt; url;
  
      loadPage(url);
  }
  
  void webkitRunnable::init()
  {
      qDebug() &lt;&lt; "WebKit--&gt; init webkit";
      webView = new QWebView;
  
      connect(webView, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
  
      manager = new QNetworkAccessManager(this);
  
      manager = webView-&gt;page()-&gt;networkAccessManager();
  
      webView-&gt;page()-&gt;setNetworkAccessManager(manager);
  
      connect(manager, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*)));
  }
  
  void webkitRunnable::finishLoading(bool)
  {
      qDebug() &lt;&lt; "WebKit--&gt; finish loading";
  }
  
  void webkitRunnable::replyFinished(QNetworkReply* Reply)
  {
      qDebug() &lt;&lt; "WebKit--&gt; reply Finished";
  }
  
  void webkitRunnable::loadPage(QUrl url)
  {
      qDebug() &lt;&lt; "WebKit--&gt; load Page";
      webView-&gt;load(url);
      webView-&gt;setFocus();
  }
  </code></pre>
  
  <p><strong>webkitrunnable.h:</strong></p>
  
  <pre><code>class webkitRunnable : public QObject, public QRunnable
  {
      Q_OBJECT
  
  public:
      webkitRunnable(QUrl inputURL);
  
      void loadPage(QUrl url);
  
  protected:
      void run();
  
  signals:
  
  public slots:
      void finishLoading(bool);
      void replyFinished(QNetworkReply*);
  
  private:
      void    init();
  
      QUrl                    url;
      QNetworkAccessManager   *manager;
      QWebView                *webView;
  };
  </code></pre>
  
  <p><strong>mythread.cpp:</strong></p>
  
  <pre><code>MyThread::MyThread(QObject *parent) :
      QObject(parent)
  {
      threadPool = new QThreadPool(this);
      threadPool-&gt;setMaxThreadCount(20);
  
      webkit = new webkitRunnable(QUrl("http://www.google.com/"));
  }
  
  MyThread::~MyThread()
  {
      delete threadPool;
  }
  
  void MyThread::startMultiThreadLoad(QUrl url)
  {
      webkit = new webkitRunnable(url);
  
      connect(webkit, SIGNAL(threadFinished(int)), this, SLOT(finished(int)), Qt::QueuedConnection);
  
      for (int i = 0; i &lt; threadPool-&gt;maxThreadCount(); i++)
      {
          threadPool-&gt;start(webkit);
          qDebug() &lt;&lt; "start(active):" &lt;&lt; threadPool-&gt;activeThreadCount();
      }
  }
  
  void MyThread::finished(int number)
  {
      qDebug() &lt;&lt; "thread number is: " &lt;&lt; number;
      qDebug() &lt;&lt; "finished(active):" &lt;&lt; threadPool-&gt;activeThreadCount();
  }
  </code></pre>
  
  <p>mythread.h:</p>
  
  <pre><code>class MyThread : public QObject
  {
      Q_OBJECT
  public:
      explicit MyThread(QObject *parent = 0);
      ~MyThread();
      void startMultiThreadLoad(QUrl url);
  
  public slots:
      void finished(int);
  
  private:
      webkitRunnable* webkit;
      QUrl            globalURL;
  
      QThreadPool     *threadPool;
  };
  </code></pre>
  
  <p>Whenever <code>webkit-&gt;load()</code> is executed, I got the following Application Output in Qt Creator:</p>
  
  <pre><code>QObject: Cannot create children for a parent that is in a different thread.
  (Parent is QNetworkAccessManager(0x6f1598), parent's thread is QThread(0x65dfd0), current thread is QThread(0x6ccd28)
  </code></pre>
  
  <p>How can I solve it? Can anyone give an example?
  Thanks</p>