Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, September 2007
How to start the QThread's eventloop


Message 1 in thread

Hello,

the docs for QThread says, to call exec() to start the thread's event loop.
My application needs queued connections, so I need to start this loop. But
something like that hangs forever:

run() {
   exec();
}

QT doesn't provide an example with threads and an started event loop. For
example inserting a call to exec() in the run() method in the mandelbrot
example makes it hang forever too.

Do I have to implement an explicit event loop?

Frank


--
 [ signature omitted ] 

Message 2 in thread

Frank wrote:
>Hello,
>
>the docs for QThread says, to call exec() to start the thread's event
> loop. My application needs queued connections, so I need to start this
> loop. But something like that hangs forever:
>
>run() {
>   exec();
>}
>
>QT doesn't provide an example with threads and an started event loop.
> For example inserting a call to exec() in the run() method in the
> mandelbrot example makes it hang forever too.

That's the correct thing to do: call exec().

You have to ask the event loop to quit, though. There's a quit() function.

-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: This is a digitally signed message part.


Message 3 in thread

I think the problem you are having is that unless you move the QThread 
object to its own thread you cannot queue connections.  Take a look at 
http://lists.trolltech.com/qt-interest/2007-09/thread00073-0.html. I 
threw a bit of sample code for what I do in one of the replies.

Brian!

Frank wrote:
> Hello,
>
> the docs for QThread says, to call exec() to start the thread's event loop.
> My application needs queued connections, so I need to start this loop. But
> something like that hangs forever:
>
> run() {
>    exec();
> }
>
> QT doesn't provide an example with threads and an started event loop. For
> example inserting a call to exec() in the run() method in the mandelbrot
> example makes it hang forever too.
>
> Do I have to implement an explicit event loop?
>
> Frank
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>   

--
 [ signature omitted ]