<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QCameraImageCapture moveToThread error]]></title><description><![CDATA[<p dir="auto">I am sort of new to Qt and am trying to sort out how to work with the QCamera and QCameraImageCapture technology.</p>
<p dir="auto">I have the QCamera and QCameraImageCapture in a thread with no ui.  The invocation of the thread is:</p>
<pre><code>QCameraImageCapture theImageCapture = new ImageCapture();
QThread* theImageThread = new QThread();
theImageCapture-&gt;moveToThread(theImageThread);

connect(theImageThread, SIGNAL(started()), theImageCapture, SLOT(process()));
connect(theImageCapture, SIGNAL(finished()), theImageThread, SLOT(quit()));

connect(theImageThread, SIGNAL(finished()), theImageThread, SLOT(deleteLater()));
theImageThread-&gt;start();
</code></pre>
<p dir="auto">The imageCapture instance instantiates a QCamera and a QCameraImageCapture.  All of this code is taken from the camera demo.</p>
<p dir="auto">the captureImage process method is:</p>
<pre><code>void ImageCapture::process()
{
    inProcess = true;
    isRunning = true;

    while (inProcess)
    {
        sync.lock();
        inProcess = isRunning;
        sync.unlock();

        if (isReadyForCapture){
            toggleLock();
            takeImage();
            toggleLock();
        }
    }
    emit finished();
}
</code></pre>
<p dir="auto">The image is sent to a widget for processing with:</p>
<pre><code>void ImageCapture::processCapturedImage(int requestId, const QImage&amp; img)
{
    Q_UNUSED(requestId);
    QImage scaledImage = img.scaled(QSize(400, 300), //ui-&gt;viewfinder-&gt;size(),
                                    Qt::KeepAspectRatio,
                                    Qt::SmoothTransformation);

    thePixmap = QPixmap::fromImage(scaledImage);
    emit ProcessPixmap(thePixmap);
}
</code></pre>
<p dir="auto">The process works for a few images before I get the message</p>
<p dir="auto">QObject::moveToThread: Current thread (0x2775377aa10) is not the object's thread (0x2775377c540).<br />
Cannot move to target thread (0x277536ad1f0)</p>
<p dir="auto">And after the message the images continue to be sent to the Widget.</p>
<p dir="auto">If I comment out the takeImage() line in the thread process line the message goes away.  I do not have a view finder connected to the camera.</p>
<p dir="auto">What did I do wrong that causes the message?</p>
<p dir="auto">Is there an alternative approach to the situation.  What I want to do is take an image periodically, get the QPixmap of the image so I can draw on it, and then write it to a Widget.</p>
]]></description><link>https://forum.qt.io/topic/73460/qcameraimagecapture-movetothread-error</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 12:42:17 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/73460.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 18 Nov 2016 05:02:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QCameraImageCapture moveToThread error on Sun, 20 Nov 2016 20:43:47 GMT]]></title><description><![CDATA[<p dir="auto">The "easy" way is to put a breakpoint in Qt's source where the message is emitted and just walk through the stack to see what call causes it.</p>
]]></description><link>https://forum.qt.io/post/360619</link><guid isPermaLink="true">https://forum.qt.io/post/360619</guid><dc:creator><![CDATA[kshegunov]]></dc:creator><pubDate>Sun, 20 Nov 2016 20:43:47 GMT</pubDate></item><item><title><![CDATA[Reply to QCameraImageCapture moveToThread error on Sat, 19 Nov 2016 16:42:58 GMT]]></title><description><![CDATA[<p dir="auto">It is interesting.  I changed the implementation to use a timer in the widget so I have no QThreads of my own and I still get the message.  Is there a way to catch the message, I get the error when I run from the ide, but when I run as a real application I can't know that something is wrong, and handle the situation or write a status.</p>
<p dir="auto">If even anything is wrong.</p>
<p dir="auto">I can show all of the capture error messages and the camera error messages and none are shown.</p>
<p dir="auto">Like I said, I am new the qt and trying to figure this out.  The message quotes a thread address, it looks like an address, is there a way to find what thread is causing the message.</p>
]]></description><link>https://forum.qt.io/post/360485</link><guid isPermaLink="true">https://forum.qt.io/post/360485</guid><dc:creator><![CDATA[nefarious]]></dc:creator><pubDate>Sat, 19 Nov 2016 16:42:58 GMT</pubDate></item><item><title><![CDATA[Reply to QCameraImageCapture moveToThread error on Fri, 18 Nov 2016 09:09:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nefarious">@<bdi>nefarious</bdi></a> said in <a href="/post/360223">QCameraImageCapture moveToThread error</a>:</p>
<blockquote>
<p dir="auto">QObject::moveToThread: Current thread (0x2775377aa10) is not the object's thread (0x2775377c540).<br />
Cannot move to target thread (0x277536ad1f0)</p>
</blockquote>
<p dir="auto">It appears you're trying to "pull" an object from a thread, so that's why Qt's complaining. <code>QObject::moveToThread</code> is NOT thread safe and can be used only from the thread the object currently resides to "push" into another.</p>
<p dir="auto">On a related note you shouldn't use pixmaps from worker threads <code>QPixmap::fromImage</code> (assuming <code>processCapturedImage</code> is run in the worker). The <code>QPixmap</code> class isn't reentrant.</p>
<p dir="auto">Kind regards.</p>
]]></description><link>https://forum.qt.io/post/360254</link><guid isPermaLink="true">https://forum.qt.io/post/360254</guid><dc:creator><![CDATA[kshegunov]]></dc:creator><pubDate>Fri, 18 Nov 2016 09:09:16 GMT</pubDate></item></channel></rss>