Results 1 to 3 of 3

Thread: QThread help please

  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QThread help please

    Hi,

    I have a console application in which I have reimplemented QCoreApplication. Also, I am creating n(sent as an argument) threads in the following manner

    Qt Code:
    1. Thread *t = new Thread(ipAdd, serialNo, noOfSecs, perSec);
    2. ++threadCount;
    3. connect(t, SIGNAL(finished()), this, SLOT(threadFinished()));
    4. connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
    5. t->start();
    To copy to clipboard, switch view to plain text mode 

    Here is the slot threadFinished()

    Qt Code:
    1. void Application::threadFinished()
    2. {
    3. --threadCount;
    4. if(threadCount == 0){
    5. exit();
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

    The above slot is never called itself and therefore I am not able to exit from the application.

    Can someone please help me with this ?
    Thanks a lot.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QThread help please

    How is Thread implemented? Does it enter to an event loop? If it enters to an event loop, is QThread::quit() ever called? If it doesn't enter to an event loop, does it ever reach the end of QThread::run()?
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QThread help please

    Oh, I think I got your point and realized my mistake.

    Thanks a lot for pointing it out.
    Thanks.

Similar Threads

  1. How can I get the thread ID out of QThread
    By Artschi in forum Qt Programming
    Replies: 9
    Last Post: 8th November 2017, 03:27
  2. how to use QHttp inside QThread in Qt3
    By alusuel in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2006, 11:19
  3. Posting custom events to a subclass of QThread
    By jpn in forum Qt Programming
    Replies: 3
    Last Post: 4th July 2006, 15:49
  4. Replies: 4
    Last Post: 10th May 2006, 22:37
  5. Is it possible to create a QThread without inheriting ?
    By probine in forum Qt Programming
    Replies: 6
    Last Post: 23rd March 2006, 22:51

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.