PDA

View Full Version : Close a thread with a signal



victor374
30th November 2007, 07:23
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!

mchara
30th November 2007, 07:33
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:


class x:public Q...
{
Q_OBJECT
...
signals:
void stopThreadSignal(void);
};