Results 1 to 3 of 3

Thread: Problem with eventloop in QThread

  1. #1
    Join Date
    Feb 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Problem with eventloop in QThread

    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?

  2. #2
    Join Date
    Feb 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Problem with eventloop in QThread

    Well, looks like IO can't have QWebPage anywhere else but main eventloop, which is GUIthread?

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with eventloop in QThread

    Have you look at QObject::moveToThread() ? Else your signals will be handled in the thread that created the new thread (your main thread in this case)

Similar Threads

  1. Replies: 1
    Last Post: 28th January 2010, 09:23
  2. QThread Problem
    By MrShahi in forum Qt Programming
    Replies: 1
    Last Post: 8th July 2009, 10:14
  3. Qthread Problem
    By sroger in forum Qt Programming
    Replies: 0
    Last Post: 2nd March 2009, 07:35
  4. QThread problem
    By MrShahi in forum Qt Programming
    Replies: 6
    Last Post: 15th July 2008, 12:28
  5. Thread eventLoop and run
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 8th May 2008, 19:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.