[Qt-interest] To start a thread without having a class derived from QThread

R. Reucher rene.reucher at batcom-it.net
Thu Mar 5 10:59:13 CET 2009


On Thu March 5 2009 10:56:25 R. Reucher wrote:
> On Thu March 5 2009 10:52:30 Hemalatha Venkataswamy wrote:
> > For using QRunnable also, it seems we need to have class derived from
> > QRunnable. is this true? I have few functions which need to be called
> > when I click a button and this should be processed in a thread so that it
> > does not disturb my main UI thread.
> >
> > Is there any example codes available?
>
> As Yves Bailly already mentioned, Qt Concurrent is your best bet. There's
> example code here:
> http://doc.trolltech.com/4.5/qtconcurrentrun.html#run
Sorry, not exactly at the #run anchor... but at the top of the page:

--
Running a Function in a Separate Thread

To run a function in another thread, use QtConcurrent::run():

extern void aFunction();
QFuture<void> future = QtConcurrent::run(aFunction);
--

I'd assume that should work for you as well.
-- 
René Reucher
rene.reucher at batcom-it.net
http://www.batcom-it.net/

Putt's Law:
	Technology is dominated by two types of people:
		Those who understand what they do not manage.
		Those who manage what they do not understand.




More information about the Qt-interest-old mailing list