<?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[QGraphicsPathItem is not getting highlighted]]></title><description><![CDATA[<p dir="auto">I have a QGraphicsView which has many symbols ( AND, OR, NOT etc )  made of various QGraphicsItem like , QGraphicsLineItem ( for straight line ), QGraphicsPathItem ( for curve ) , QGraphicsEllipseItem ( for circle )</p>
<p dir="auto">All these QGraphicsItem, I have bundled in QGraphicsItemGroup.<br />
I have a Search feature, which takes name of symbol and search it in view and once found highlihgt that symbol.<br />
I have a zoom in feature, which zoomed in the view with pre defined scale.</p>
<p dir="auto">Issue :</p>
<ol>
<li>When I search symbol, except symbol's arc, all the part gets highlighted.</li>
<li>When I zoom in, arc of symbol gets disappear.</li>
</ol>
<p dir="auto">Here are screen shots :</p>
<p dir="auto">Original  symbol<br />
<img src="https://ddgobkiprc33d.cloudfront.net/4b330f23-08f3-4652-9fdb-ad9258ecdc40.PNG" alt="sym1.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">After search, whole symbol should get highlight, but here arc is not getting highlighted.<br />
<img src="https://ddgobkiprc33d.cloudfront.net/15a1e6bd-7101-4ab3-a24a-43816a194772.PNG" alt="sym2.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">After zoom in, arc is getting disappear<br />
<img src="https://ddgobkiprc33d.cloudfront.net/72a839df-4013-4c8c-ba94-f3d91790a3a0.PNG" alt="sym3.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">Code :<br />
In searchSymbol feature, there is a function to highlight symbol.</p>
<pre><code>class myGroup : public QGraphicsItemGroup
class myArc: public QGraphicsPathItem
class myLine: public QGraphicsLineItem 
class myEllipse: public QGraphicsEllipseItem
</code></pre>
<pre><code>void myViewer::HighLightSymbol(QGraphicsItemGroup* symAddress)
{
    QList&lt;QGraphicsItem*&gt; childItems = symAddress-&gt;childItems();
    QPen mPen(Qt::SolidLine);
    mPen.setWidth(2);
    foreach (QGraphicsItem* chItem, childItems) {
       
      //if (myArc* poly = dynamic_cast&lt;myArc*&gt;(chItem))
        if (QGraphicsPathItem* poly = dynamic_cast&lt;QGraphicsPathItem*&gt;(chItem)) {
            qDebug()&lt;&lt;"HighLightSymbol Arc ----&gt; "&lt;&lt;poly;
            poly-&gt;setPen(mPen);
        } else {
            if (myLine* line = dynamic_cast&lt;myLine*&gt;(chItem)) {
                qDebug()&lt;&lt;"HighLightSymbol line ----&gt; "&lt;&lt;line;
                line-&gt;setPen(mPen);
            } else {
                if (myEllipse* ell = dynamic_cast&lt;myEllipse*&gt;(chItem)) 
                    ell-&gt;setPen(mPen);
            }
        }
    }
}
</code></pre>
<p dir="auto">In above code, I have printed all the  QGraphicsPathItem* poly and  myLine* line. There address is exactly same as when symbol has created.</p>
<p dir="auto">I know it is very difficult to guess issue from limited code. But still, if anyone has any suggestion, please provide it so atleast I will get some idea to debug.</p>
]]></description><link>https://forum.qt.io/topic/139428/qgraphicspathitem-is-not-getting-highlighted</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 07:11:06 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139428.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 Sep 2022 14:29:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QGraphicsPathItem is not getting highlighted on Thu, 22 Sep 2022 05:00:39 GMT]]></title><description><![CDATA[<p dir="auto">Connect a slot to the QGraphicsScene::selectionChanged() signal. In the slot, retrieve the QList of selected items QGraphicsScene::selectedItems(). Use that list to change the colors. If you keep a copy of the previous selections (initially empty), then you can change the colors only for the items that are not common to the old and new selection lists for better efficiency.</p>
]]></description><link>https://forum.qt.io/post/729685</link><guid isPermaLink="true">https://forum.qt.io/post/729685</guid><dc:creator><![CDATA[Jameswalter]]></dc:creator><pubDate>Thu, 22 Sep 2022 05:00:39 GMT</pubDate></item></channel></rss>