[Kde-perl] QThread anyone?

Germain Garand germain at ebooksfrance.org
Fri May 9 13:28:01 CEST 2003


Le Lundi 05 Mai 2003 05:54, Ringwraith a écrit :
> Hey guys... I have a "dumb" question, but I am learning.. Is there
> anyway I can use QThread? when i call a new instance of it it says no
> method call for Qt::Thread. And if there is a way would i have to have a
> perl interpreter with threads support?
>

Hi,
The only practical way you could use threads with PerlQt would be through 
ithreads (so, yes, you'd need to have those built in your interpreter, as 
well as a thread-enabled Qt) and passing messages (e.g Qt::CustomEvents )to 
Qt::Application::postEvent

That's not possible now though, since PerlQt isn't thread safe at all.
I'll dig into that for the next release, it looks interesting. 

>
> Also, the reason why I am asking this is basically, I have a wizard
> where at one point when the user clicks next, it will start to copy
> files and update a progress bar. I do not want the program to appear to
> hang during the copy process, I've tried fork, but from reading the
> perldocs on fork it looks like it may be a fuss to get it working
> properly along side with perlqt. Can someone suggest a better way to go
> about this?

I'd suggest you use a simple Qt::Process. You can easily communicate through 
stdin/stdout in a full OO way, triggering a slot when data is received.

If the process you'd use is another Perl program, then I'd recommend you:
   select(STDOUT); $| = 1;
to unbuffer STDOUT

Germain



More information about the Kde-perl mailing list