Results 1 to 2 of 2

Thread: Close a thread with a signal

  1. #1
    Join Date
    Nov 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Close a thread with a signal

    Hi!. How can i close (or quit()) a thread from the calling process?. I'm trying to send a signal to the thread object to quit it but i dont know how, what kind of signal should i send? and how? any sugestion would help. Thanks!

  2. #2
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Close a thread with a signal

    Hi,
    thing is qthread can't receive signals or events if it's not processing event loop.
    see QThread::exec() and QCoreApplication::processEvents()

    u may use any signal because even if signal has some parameters, you can connect it to slot that have no(and quit() haven't). You can also(more elegant way) provide own signal:
    Qt Code:
    1. class x:public Q...
    2. {
    3. Q_OBJECT
    4. ...
    5. signals:
    6. void stopThreadSignal(void);
    7. };
    To copy to clipboard, switch view to plain text mode 
    Last edited by mchara; 30th November 2007 at 06:41.
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

Similar Threads

  1. Can you send a signal to a thread?
    By Dumbledore in forum Qt Programming
    Replies: 1
    Last Post: 9th November 2007, 20:31
  2. creating treeWidgetItem using emitted signal from thread class
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2007, 08:37
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  5. simple thread layout question
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2006, 11:02

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.