lynchkp
9th September 2012, 00:31
Hello,
I have an algorithm which runs on image data, which I have implemented so that it occurs on a separate QThread to prevent locking the GUI. This works perfectly when I am running it with one image. Instead, I'd like to run a loop over multiple images, but only one thread executing at a time... something along the lines of...
// Loop over all files.
int i = 0;
while (i < selected_files.size()) {
QThread* thread = new QThread;
Worker *worker = new Worker(filenames,s2);
worker->moveToThread(thread);
connect(thread, SIGNAL(started()), worker, SLOT(process()));
connect(worker, SIGNAL(finished()), thread, SLOT(quit()));
thread->start();
i+=step;
}
But it currently runs all the threads at the same time. I want this to operate one thread at a time. I know this is probably very basic, but I am still learning threaded programming!
Thanks!
I have an algorithm which runs on image data, which I have implemented so that it occurs on a separate QThread to prevent locking the GUI. This works perfectly when I am running it with one image. Instead, I'd like to run a loop over multiple images, but only one thread executing at a time... something along the lines of...
// Loop over all files.
int i = 0;
while (i < selected_files.size()) {
QThread* thread = new QThread;
Worker *worker = new Worker(filenames,s2);
worker->moveToThread(thread);
connect(thread, SIGNAL(started()), worker, SLOT(process()));
connect(worker, SIGNAL(finished()), thread, SLOT(quit()));
thread->start();
i+=step;
}
But it currently runs all the threads at the same time. I want this to operate one thread at a time. I know this is probably very basic, but I am still learning threaded programming!
Thanks!