[Interest] QThread and QPixmap::grabWindow()
alexmalvtk at gmail.com
Thu Aug 8 01:21:10 CEST 2013
As far as I understand you need to make sure that window is grabbed in the
So the clean way to do it - do it in the main threat without changing
and wait until picture is taken in the threat you need a picture at.
This will also remove race conditions you are facing - your
grabWindow might be called from different threads and more of that it
might be called at the same time as painting occur, which should not
You can't avoid synchronization here. It is your choice through events.
mutexes or signal/slots . I would personally prefer last with
On Wed, Aug 7, 2013 at 3:11 PM, Alexander Syvak <alexander.svk at gmail.com>wrote:
> there's a need for each thread to make screenshots and to compare them
> with loaded picture using QImage.
> Since there's only on GUI thread, I moved the the thread context to the
> main thread to make the screenshot in there.
> Here's the code snipper from the worker-threads:
> QPixmap screenshot;
> auto const this_thread = this->thread();
> screenshot = QPixmap::grabWindow( QApplication::desktop()->winId() );
> // Compare it with the trigger if there was no match before.
> if ( !matched && event_p && event_p->get_trigger_path().size() && images_comparator::cmp( screenshot.toImage(), QImage( event_p->get_trigger_path() ), pattern() ) )
> qDebug() << "!!! matched !!!";
> matched = true;
> However, the grabWindow returns null QPixmap always.
> Who knows how to achive what's needed here?
> Interest mailing list
> Interest at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest