<?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[Casting a auto_ptr&lt;QWidget&gt; to QWidget]]></title><description><![CDATA[<p dir="auto">Hi I am trying to cast a auto_ptr&lt;QWidget&gt; to a QWidget. I have tried multiple things : including</p>
<p dir="auto">std::auto_ptr&lt;QWidget&gt; nativeWidget;<br />
QWidget widget=static_cast&lt;auto_ptr&lt;QWidget&gt; &gt;(nativeWidget);</p>
<p dir="auto">It gives me an error that std::auto_ptr&lt;QWidget&gt; cannot be cast as a QWidget.<br />
How can I cast it?</p>
]]></description><link>https://forum.qt.io/topic/63451/casting-a-auto_ptr-qwidget-to-qwidget</link><generator>RSS for Node</generator><lastBuildDate>Thu, 07 May 2026 13:15:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/63451.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 28 Jan 2016 08:29:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Casting a auto_ptr&lt;QWidget&gt; to QWidget on Thu, 28 Jan 2016 12:28:32 GMT]]></title><description><![CDATA[<p dir="auto">If you have C++11 capabilities then you are better using <code>std::unique_ptr&lt;T&gt;</code>, <code>std::auto_ptr&lt;T&gt;</code> is deprecated. That too has <code>std::unique_ptr&lt;T&gt;::get()</code> to access the raw pointer and <code>std::unique_ptr&lt;T&gt;::release()</code> to take over ownership of the object pointed to.</p>
]]></description><link>https://forum.qt.io/post/310065</link><guid isPermaLink="true">https://forum.qt.io/post/310065</guid><dc:creator><![CDATA[bsomervi]]></dc:creator><pubDate>Thu, 28 Jan 2016 12:28:32 GMT</pubDate></item><item><title><![CDATA[Reply to Casting a auto_ptr&lt;QWidget&gt; to QWidget on Thu, 28 Jan 2016 09:02:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sunil.nair">@<bdi>sunil.nair</bdi></a><br />
anyway, there is no need to do a cast in your case:</p>
<pre><code>QWidget* widget = nativeWidget.get(); // or use release(); read the docs to see what is more applicable for your usecase
</code></pre>
]]></description><link>https://forum.qt.io/post/310026</link><guid isPermaLink="true">https://forum.qt.io/post/310026</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Thu, 28 Jan 2016 09:02:27 GMT</pubDate></item><item><title><![CDATA[Reply to Casting a auto_ptr&lt;QWidget&gt; to QWidget on Thu, 28 Jan 2016 08:54:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sunil.nair">@<bdi>sunil.nair</bdi></a><br />
Since QWidget derives from QObject, there are no assignment/copy operators available. You need to use only pointer types (unless you <strong>construct</strong> it on the stack)</p>
]]></description><link>https://forum.qt.io/post/310017</link><guid isPermaLink="true">https://forum.qt.io/post/310017</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Thu, 28 Jan 2016 08:54:08 GMT</pubDate></item></channel></rss>