[Interest] QThread and QPixmap::grabWindow()
Alexander Syvak
alexander.svk at gmail.com
Thu Aug 8 00:11:09 CEST 2013
Hello,
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;
try
{
auto const this_thread = this->thread();
moveToThread(QApplication::instance()->thread());
screenshot = QPixmap::grabWindow( QApplication::desktop()->winId() );
moveToThread(this_thread);
screenshots.append(screenshot);
// 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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130808/e77aa40c/attachment.html>
More information about the Interest
mailing list