[Qt-interest] QThread eventloop problems

Sergey Shekyan sergio_arm at yahoo.com
Thu Feb 25 20:54:14 CET 2010


Thing is I don't have GUI. For now I am building my app as VNC server.
I designed it as multithreaded, as it is a server, which serves IPC requests from network,
gets the link to be loaded, creates a thread with QWebPage instance
there, loads the page, then send the response back to IPC, and
everything was working so far, and I was thinking about cahnging it to
Thread pool, until I started to load pages, which need some refresh
action, like window.location change. In that case second loadFinished()
event is not fired at ll in QThread, but fires nice in main GUI thread,
if I create QWebPage there.That gives me a suspect that something is
wrong with my event loop in thread. 
 
However, it looks like I cant' have QWebPage in QThread as it has reference to QWidget internally, and can only be instantiated in GUI thread... 
So
your idea is good, and I'll move QWebPage objects to main thread, and
will have IPC communication multithreaded, or could even move it to
main thread either.



________________________________
From: Jason H <scorp1us at yahoo.com>
To: Sergey Shekyan <sergio_arm at yahoo.com>; qt-interest at trolltech.com
Sent: Thu, February 25, 2010 11:25:10 AM
Subject: Re: [Qt-interest] QThread eventloop problems


I have no idea why would want to load pages in a thread when the Qt networking classes are async. I'd keep them all in the main thread. There is only a small performance hit on the one CPU having all the IO loaded on it. Unless you're doing a lot of SSL, it shouldn't matter.





________________________________
From: Sergey Shekyan <sergio_arm at yahoo.com>
To: qt-interest at trolltech.com
Sent: Thu, February 25, 2010 12:50:20 PM
Subject: [Qt-interest] QThread eventloop problems


Hi, 

I am trying to have multithreaded app with QWebPage isntance in every thread. 
the way I am creating it is:


void
 MyServer::incomingConnection(int socketDescriptor)
  {
    MyThread* thread = new MyThread(this, socketDescriptor);
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    thread->start();
   }

and run() of MyThread is:
void
  MyThread::run(){
    MyPage page(sockfd);
    exec();
  }

where, MyPage is subclassed from QObject, and has QWebPage member pointer, and slots to handle signals from QWebPage. 

So the problem is everything works if I am creating MyPage in main event loop, and looks like I don't have the event loop, and no signals of QWebPage are triggered if MyPage is in MyThread. 
What am I doing wrong?


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100225/80055e50/attachment.html 


More information about the Qt-interest-old mailing list