<?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[Move QPixmap to QLabel]]></title><description><![CDATA[<p dir="auto">Could I move QPixmap into the QLabel?<br />
I haven't found any member function which support<br />
move semantics or some function could move the QPixmap into the QLabel<br />
even in Qt5.The original solution of QLabel is copy the<br />
QPixmap you pass into the function.</p>
<p dir="auto">If I haven't missed any fucntions Qt provided, what kind of<br />
technical reason QLabel do not support move semantics<br />
or just provide the users a simple function to send the resource into<br />
the QLabel but not copy.</p>
<p dir="auto">Thanks a lot</p>
]]></description><link>https://forum.qt.io/topic/21460/move-qpixmap-to-qlabel</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 12:52:03 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/21460.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Nov 2012 08:05:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Move QPixmap to QLabel on Fri, 16 Nov 2012 08:44:27 GMT]]></title><description><![CDATA[<p dir="auto">Thanks, but this looks like copy<br />
According to the declaration<br />
setPixmap(QPixmap const &amp;)<br />
Const&amp; wouldn't increase reference count<br />
I don't think they will share the same resource</p>
<p dir="auto">and the implementation looks more like copy than move</p>
<p dir="auto">@<br />
void QLabel::setPixmap(const QPixmap &amp;pixmap)<br />
{<br />
Q_D(QLabel);<br />
if (!d-&gt;pixmap || d-&gt;pixmap-&gt;cacheKey() != pixmap.cacheKey()) {<br />
d-&gt;clearContents();<br />
d-&gt;pixmap = new QPixmap(pixmap);<br />
}</p>
<pre><code>if (d-&gt;pixmap-&gt;depth() == 1 &amp;&amp; !d-&gt;pixmap-&gt;mask())
    d-&gt;pixmap-&gt;setMask(*((QBitmap *)d-&gt;pixmap));

d-&gt;updateLabel();
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">looks like the QLabel will create a brand new copy of the QPixmap<br />
if the d-&gt;pixmap do not point to anything or they don't have the<br />
same cacheKey.</p>
<p dir="auto">But the behavior I want is something like<br />
@<br />
QPixmap *temp = origin_pixmap;<br />
origin_pixmap = new_pixmap;<br />
temp-&gt;release()<br />
@</p>
<p dir="auto">or<br />
@<br />
std::string A, B;<br />
//.............<br />
A = std::move(B);<br />
@</p>
]]></description><link>https://forum.qt.io/post/157175</link><guid isPermaLink="true">https://forum.qt.io/post/157175</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 16 Nov 2012 08:44:27 GMT</pubDate></item><item><title><![CDATA[Reply to Move QPixmap to QLabel on Fri, 16 Nov 2012 08:20:18 GMT]]></title><description><![CDATA[<p dir="auto">@ QLabel label;<br />
label.setPixmap(pixmap);@</p>
]]></description><link>https://forum.qt.io/post/157173</link><guid isPermaLink="true">https://forum.qt.io/post/157173</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 16 Nov 2012 08:20:18 GMT</pubDate></item></channel></rss>