0

In a QThread based class, I have a QWebPage, when loadFinished(), I need to parse the contents, it would stuck the UI. So I put everything in a thread:

class Thread: public QThread
{
   public:
      Thread (QObject *p): QThread (p)
      {
         moveToThread (this);
         connect (&page, SIGNAL(loadFinished(bool)), SLOT(loadFinished(bool)));
      }
   private slots:
      void loadFinished (bool ok)
      { 
         // never get called, unless I remove the `moveToThread(this)`
      }
};

I also tried to move the event of QWebPage to this qthread based class as well, I got errors, seems you can't move the event to a new thread.

Any ideas on it?

daisy
  • 22,498
  • 29
  • 129
  • 265

1 Answers1

0

Unfortunately, Qt GUI elements can't be created on a separate thread than the main GUI thread. If you are trying to compensate for GUI slow downs due to resource loading in the QWebPage, I completely understand your thought process. I have thoroughly investigated this issue and haven't found too clear of an answer yet.

There has been a reported bug for proxy lookups in Windows taking a long time: https://bugreports.qt-project.org/browse/QTBUG-10106 This bug is currently unresolved, but may have a resolution in the future.

Cameron Tinker
  • 9,634
  • 10
  • 46
  • 85