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

Qt-interest Archive, May 2008
QThread questions


Message 1 in thread

Hi List,
I'm new to QT and just started to learn. So please, be patient with me guys.

So, I've 2 questions related to QThreads:

1) How can the "main thread" send some data to a specific Qthread or vice
versa ?
With signal ? Is it possible ?

2) Suppose I've started "N" threads and they're all doing some long
computation (computation is without importance here).
Could it be possible to send a signal to all of them from the "main thread"
and tell them to exit gracefully?
Stop their computation and exit gracefully ?

Code will be very helpful guys.

Thanks in advance.

Regards,
F.

Message 2 in thread

________________________________

From: ferrety ferrety [mailto:yferrety@xxxxxxxxx] 
Sent: Saturday, May 24, 2008 4:20 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: QThread questions

 

Hi List,

 

I'm new to QT and just started to learn. So please, be patient with me
guys.

 

So, I've 2 questions related to QThreads:

 

1) How can the "main thread" send some data to a specific Qthread or
vice versa ?

With signal ? Is it possible ?

 

Yes... Send a signal.. QT 4.X handles cross thread signals and slots
just fine..

 

2) Suppose I've started "N" threads and they're all doing some long
computation (computation is without importance here).

Could it be possible to send a signal to all of them from the "main
thread" and tell them to exit gracefully?

Stop their computation and exit gracefully ?

 

Sure... Send a signal.. and on the threads slot, set a flag to stop..
Make sure your computation engine checks for the flag...  

 

Code will be very helpful guys.

 

Thanks in advance.

 

Regards,

F.


Message 3 in thread

Hi,

On Sunday 25 May 2008 00:20:28 ferrety ferrety wrote:
> Hi List,
> I'm new to QT and just started to learn. So please, be patient with me
> guys.
Welcome!

> Code will be very helpful guys.
Take a look at the Mandelbrot example. This demonstrates both of these 
features - well almost, it uses a signal form the worker thread to pass the 
result to the main thread but the idea is symmetric to what you want.

ATB,

Sean

--
 [ signature omitted ] 

Message 4 in thread

* Sean Harmer <sean.harmer@xxxxxxxxxxxxxxxxx> [Sun, 25 May 2008 10:18:38 
+0100]:
> Hi,
>
> On Sunday 25 May 2008 00:20:28 ferrety ferrety wrote:
> > Hi List,
> > I'm new to QT and just started to learn. So please, be patient with 
me
> > guys.
> Welcome!
>
> > Code will be very helpful guys.
> Take a look at the Mandelbrot example. This demonstrates both of these
> features - well almost, it uses a signal form the worker thread to 
pass
> the
> result to the main thread but the idea is symmetric to what you want.
>
> ATB,
>
> Sean
I don't think this example is symmetric because signal *from* QThread is 
performed in object slots (in thread in which he is ).
And Signal from main program can't execute in threads such as in 
mandelbrot example (this thread don't have QEventLoop)
--
 [ signature omitted ] 

Message 5 in thread

Hi,

On Sunday 25 May 2008 10:26:06 Perepelica Alexander wrote:
> I don't think this example is symmetric because signal *from* QThread is
> performed in object slots (in thread in which he is ).
> And Signal from main program can't execute in threads such as in
> mandelbrot example (this thread don't have QEventLoop)
True. I wasn't particularly clear. I simply meant to get across that both his 
problem and the example use queued connections which depend upon having the 
event loop running in the receiving thread but as you point out it doesn't 
require the emitting thread to have an event loop.

Thanks for clarifying :-)

Sean

--
 [ signature omitted ]