PDA

View Full Version : Thread eventLoop and run



^NyAw^
8th May 2008, 15:06
Hi,

Can a QThread call "exec()" on "run()" method and then do some work or "exec()" locks?

I need to call "exec()" because the Thread have a Socket so the events have to be sended to this Thread, but also have to do som work:



MyThread::run()
{
if (!m_qSocket.setSocketDescriptor(m_iSocketDescripto r))
{
return;
}
bool bC = connect(&m_qSocket,SIGNAL(readyRead()),this,SLOT(llegirDade s()));
bool bC2 = connect(&m_qSocket,SIGNAL(disconnected()),this,SLOT(descone xio()));
exec();
//Here I need to do some work:
...
//more work, ...
...
}


Thanks,

Lesiok
8th May 2008, 17:39
Hint : QApplication::processEvents()

bunjee
8th May 2008, 19:36
void ZePurpleThread::run()
{
QEventLoop eventLoop;

while (mPurpleApi->isLoop())
{
eventLoop.processEvents(QEventLoop::AllEvents);
}

// More stuff...
}