A good point to start is always the documentation of Qt: Thread Support in Qt. And then ervery book for Qt handles threads.
A good point to start is always the documentation of Qt: Thread Support in Qt. And then ervery book for Qt handles threads.
^Nisok^ (17th April 2009)
ok. So as far as I understand I have to subclass my class from QThread. But what if I want to subclass it from another custom class.
In order to be more specific...
I read the data from a list file, then I process the data to produce an image. But I want to have a periodical check or new data. My first thought was to create a new thread which will be responsible of doing this check and then provide the new data to the process class.
If your check for new data is quick (I guess so) just use a timer inside your main app. If data chanced use/fire a worker thread .
You also can use signal and slots across the thread borderMy first thought was to create a new thread which will be responsible of doing this check and then provide the new data to the process class.
If I create a l class from a parent which runs on a separate thread then this class will also run on this thread?
all objects which have been created in QThread::run will be in this thread.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Ok, thanks and one final question on this tread. On the worker thread I created I have a matrix which I want to transfer to a class on the main thread, is there something I have to take care of, I heard that in order to communicate a thread with the main thread I have to setup a transaction, do you know a guide or something?
anyone?
How to transfer data from a worker thread to the main thread?
you need use QMutext/QMutexLocker, QReadWriteLock, QSemaphore, and QWaitCondition.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
But this way will I lock the main thread during the data transfer??
you need lock that thread which modify data and then you can send that data to another thread using signals or events.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Bookmarks