Skip to content
Snippets Groups Projects
Commit 171d7113 authored by Matthias Möller's avatar Matthias Möller
Browse files

add more information about reimplementing OpenFlipperThread

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20246 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 786db3fb
No related branches found
No related tags found
No related merge requests found
......@@ -258,14 +258,43 @@ A quick example for stating a thread:
thread->startProcessing(); // start processing
\endcode
Note: If your class is derived from OpenFlipperThread and reimplements the
run() function, you might also want to connect the signal OpenFlipperThread::state()
Note: If your class is derived from OpenFlipperThread, do not reimplement the
\a run() function. Instead, use the \a function(QString)
to connect the your running function with \a Qt::DirectConnection. Short example:
Be \a MyThread the derived thread class
\code{.cpp}
class MyThread : public OpenFlipperThread
\endcode
and \a parallelFunction(QString) the function which should run by different threads.
\code
void MyThread::parallelFunction(QString) // function which will run in parallel
{
std::cout << "I am running in another thread." << currentThreadId() << std::endl;
}
\endcode
Instead of reimplementing the run function, connect the \a parallelFunction(QString) with
the \a function(QString) signal in e.g. the constructor:
\code
MyThread::MyThread(QString _jobId):OpenFlipperThread(_jobId)
{
// connect signal function(QString) with the self defined slot function
connect(this,SIGNAL(function(QString)),this,SLOT(parallelFunction(QString)), Qt::DirectConnection);
}
\endcode
Note: The OpenFlipperThread will not be notified about job cancelling. You plugin
has to be aware of it.
Note: You might also want to connect the signal OpenFlipperThread::state()
to the plugin's signal setJobState():
\code
connect(thread, SIGNAL(state(QString, int)), this, SIGNAL(setJobState(QString, int)));
\endcode
Use signal OpenFlipperThread::state() within your run() function in order to
correctly update the job's state.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment