<?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[shared_ptr QGraphicsPixmapItem QGraphicsScene::clear()]]></title><description><![CDATA[<pre><code>// header
class MyQt : public QMainWindow
{
    Q_OBJECT
...

private slots:
     void on_loadImageButton_clicked()
...

private:
    std::shared_ptr&lt;QGraphicsScene&gt; myScene;
    std::shared_ptr&lt;QGraphicsPixmapItem&gt; myManagedItem;
}

// Implementierung
void MyQt::on_loadImageButton_clicked()
{
    myScene-&gt;clear();
    myManagedPixmapItem = std::shared_ptr&lt;QGraphicsPixmapItem&gt;(myScene-&gt;addPixmap(imagePath));
</code></pre>
<p>Mit obenem Code habe ich leider folgendes Problem:<br />
beim ersten Klick ist das Bild richtig dargestellt, aber beim zweiten Klick wird kein Bild zu sehen. Zum dritmal tritt ein Bebug Error auf</p>
<blockquote>
<p>Program:c:\qt\5.4\msvc2013_64\bin\qt5cored.dll Module:5.4.2 File:global\qglobal.cpp Line:2876 ASSERT failture in QEvent:&quot;Impossible, this can't happen: QEventPrivate isn't defined anywhere&quot;, file kernel\qcoreevent.cpp, lin 328</p>
</blockquote>
<p>Wenn die beiden Variablen als raw pointer deklärt, dann geht es flott.<br />
Ohne myScene-&gt;clear() funktioniert es auch.</p>
<p>Als Newbie würde ich sehr gerne wissen, woran das Problem liegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/339988/shared_ptr-qgraphicspixmapitem-qgraphicsscene-clear</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 15:21:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/339988.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Oct 2016 13:23:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to shared_ptr QGraphicsPixmapItem QGraphicsScene::clear() on Wed, 12 Oct 2016 13:23:02 GMT]]></title><description><![CDATA[<pre><code>// header
class MyQt : public QMainWindow
{
    Q_OBJECT
...

private slots:
     void on_loadImageButton_clicked()
...

private:
    std::shared_ptr&lt;QGraphicsScene&gt; myScene;
    std::shared_ptr&lt;QGraphicsPixmapItem&gt; myManagedItem;
}

// Implementierung
void MyQt::on_loadImageButton_clicked()
{
    myScene-&gt;clear();
    myManagedPixmapItem = std::shared_ptr&lt;QGraphicsPixmapItem&gt;(myScene-&gt;addPixmap(imagePath));
</code></pre>
<p>Mit obenem Code habe ich leider folgendes Problem:<br />
beim ersten Klick ist das Bild richtig dargestellt, aber beim zweiten Klick wird kein Bild zu sehen. Zum dritmal tritt ein Bebug Error auf</p>
<blockquote>
<p>Program:c:\qt\5.4\msvc2013_64\bin\qt5cored.dll Module:5.4.2 File:global\qglobal.cpp Line:2876 ASSERT failture in QEvent:&quot;Impossible, this can't happen: QEventPrivate isn't defined anywhere&quot;, file kernel\qcoreevent.cpp, lin 328</p>
</blockquote>
<p>Wenn die beiden Variablen als raw pointer deklärt, dann geht es flott.<br />
Ohne myScene-&gt;clear() funktioniert es auch.</p>
<p>Als Newbie würde ich sehr gerne wissen, woran das Problem liegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2511340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2511340</guid><dc:creator><![CDATA[softw_de]]></dc:creator><pubDate>Wed, 12 Oct 2016 13:23:02 GMT</pubDate></item><item><title><![CDATA[Reply to shared_ptr QGraphicsPixmapItem QGraphicsScene::clear() on Wed, 12 Oct 2016 14:06:13 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>beim zweiten Aufruf, wird das QGraphicsPixmapItem-Objekt vom ersten Aufruf gelöscht. Du bist aber nicht dafür verantwortlich, Qt-Objekte zu löschen.<br />
Keine Ahnung, was das dann für Auswirkungen hat, aber scheinbar keine guten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2511343</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2511343</guid><dc:creator><![CDATA[Jockelx]]></dc:creator><pubDate>Wed, 12 Oct 2016 14:06:13 GMT</pubDate></item><item><title><![CDATA[Reply to shared_ptr QGraphicsPixmapItem QGraphicsScene::clear() on Wed, 12 Oct 2016 15:00:49 GMT]]></title><description><![CDATA[<p>Warum geht das Löschen mit raw pointern einwandfrei?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2511349</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2511349</guid><dc:creator><![CDATA[softw_de]]></dc:creator><pubDate>Wed, 12 Oct 2016 15:00:49 GMT</pubDate></item><item><title><![CDATA[Reply to shared_ptr QGraphicsPixmapItem QGraphicsScene::clear() on Wed, 12 Oct 2016 15:14:43 GMT]]></title><description><![CDATA[<p>Löscht du denn die raw-pointer? Also rufst du vorher delete auf?<br />
Denke nicht, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2511351</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2511351</guid><dc:creator><![CDATA[Jockelx]]></dc:creator><pubDate>Wed, 12 Oct 2016 15:14:43 GMT</pubDate></item><item><title><![CDATA[Reply to shared_ptr QGraphicsPixmapItem QGraphicsScene::clear() on Thu, 13 Oct 2016 10:14:28 GMT]]></title><description><![CDATA[<p>Du hast recht. Delete der Objekte habe ich nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2511438</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2511438</guid><dc:creator><![CDATA[softw_de]]></dc:creator><pubDate>Thu, 13 Oct 2016 10:14:28 GMT</pubDate></item></channel></rss>