Am 08.08.2013 00:11, schrieb Alexander Syvak:
[...] auto const this_thread = this->thread (); moveToThread (QApplication::instance()->thread()); screenshot = QPixmap::grabWindow( QApplication::desktop()->winId() ); moveToThread(this_thread); [...]
I think you might have a problem in understanding threads and the thread context as used in Qt. moveToThread() does NOT change the thread the current code runs in! It only changes the target for events sent to this object.
In your example, the thread that executes this->thread() is identical to the one that executes QPixmap::grabWindow().
You will have to implement synchronization between the main (GUI) thread and your workers. The workers send an event to the main thread each time they need a screenshot, the main thread picks up the event, takes the screenshot and sends an event back to the "caller". The addressed worker thread then picks up this event and processes the screenshot.
If you have only one worker, you might wrap up your processing in a single method and use QtConcurrent::run().
Best Regards / Mit freundlichen Grüßen Rainer Wiesenfarth -- Software Engineer | Trimble Imaging Division Rotebühlstraße 81 | 70178 Stuttgart | Germany Office +49 711 22881 0 | Fax +49 711 22881 11 http://www.trimble.com/imaging/ | http://www.inpho.de/ Trimble Germany GmbH, Am Prime Parc 11, 65479 Raunheim Eingetragen beim Amtsgericht Darmstadt unter HRB 83893, Geschäftsführer: Dr. Frank Heimberg, Hans-Jürgen Gebauer
smime.p7s
Description: S/MIME Kryptografische Unterschrift
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest