[Qt-interest] QRunnable question

Philippe philwave at gmail.com
Tue May 4 12:43:23 CEST 2010


This should work.

Note: because of an API design flaw that Nokia does not want to admit, you won't be able to sleep in your QRunnable code, by using QThread::sleep(...) since this API is "Static protected". Or you have to trick the API.

Apart that, the thread pool is a nice API that works very well for me.

Philippe

On Tue, 4 May 2010 15:56:40 +0530
amulya rattan <talk2amulya at gmail.com> wrote:

Forgot to add that I have already considered QtConcurrent. Spent a lot time on it, learnt, implemented but later found out that only sequence that it works on are QList and QVector or sequential containers. I have my task using QMap, an associative one, so that leaves me stranded...
> 
> On Tue, May 4, 2010 at 3:53 PM, amulya rattan <talk2amulya at gmail.com> wrote:
> Guys, 
>> 
>> 
>> Since QRunnable doesn't inherit from QObject, can i do this:
>> 
>> 
>> class MyTask : public QObject, public QRunnable
>> {
>>     Q_OBJECT
>> protected:
>>     void run()
>>     {
>>        qDebug() << "asdfa";
>>     }
>> }
>> 
>> 
>> and expect signal/slots to work? The reason I'd like this to work is i dont want to use QThread, but QThreadPool. My application has a lot of threads already running which i'd like to take advantage of. Secondly, task is heavy so more the threads are working on it, better it would be.
>> 
>> 
>> Appreciate any input.
>> 
>> 
>> Thanks,
>> ~Amulya



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100504/73fd94a9/attachment.html 


More information about the Qt-interest-old mailing list