<?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[Odd behaviour with QPen&#x2F;QColor]]></title><description><![CDATA[<p dir="auto">I have a widget that is displayed on top of another widget (imageView), and has the following attributes set in the ctor:</p>
<pre><code>        setAttribute(Qt::WA_TransparentForMouseEvents);
        setAttribute(Qt::WA_NoSystemBackground);
        setAttribute(Qt::WA_WState_ExplicitShowHide);
</code></pre>
<p dir="auto">This code in its paintEvent:</p>
<pre><code>        QPainter painter(this);
        QColor colour{ QColorConstants::Cyan };
        colour.setAlpha(128);
        QPen pen(colour, 1.0);

        if (pt1_ != pt2_)
        {
            QPointF p1 = imageView-&gt;imageToScreen(pt1_);
            if (p1.x() &lt; 0.5) p1.rx() = 0.5;
            if (p1.y() &lt; 0.5) p1.rx() = 0.5;
            QPointF p2 = imageView-&gt;imageToScreen(pt2_);
            if (p2.x() &lt; 0.5) p2.rx() = 0.5;
            p2.ry()--;
            QPointF p3 = imageView-&gt;imageToScreen(pt3_);
            p3.rx()--;  p3.ry()--;
            QPointF p4 = imageView-&gt;imageToScreen(pt4_);
            if (p4.x() &lt; 0.5) p4.rx() = 0.5;
            p4.ry()--;
            painter.drawLine(p1, p2);
            painter.drawLine(p2, p3);
            painter.drawLine(p3, p4);
            painter.drawLine(p4, p1);
        }
</code></pre>
<p dir="auto">mostly works fine <em>except</em> that the line drawn is white and not semi-transparent???</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/ff9e9f08-6d56-4f2b-a3d4-fc0c1dd4d7b9.png" alt="ea507303-18a0-4fa4-9903-a28765e12c3b-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Am I missing something obvious here?</p>
<p dir="auto">Thanks<br />
David</p>
]]></description><link>https://forum.qt.io/topic/146094/odd-behaviour-with-qpen-qcolor</link><generator>RSS for Node</generator><lastBuildDate>Tue, 10 Nov 2026 08:30:19 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/146094.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 29 Jun 2023 12:04:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Odd behaviour with QPen&#x2F;QColor on Thu, 29 Jun 2023 12:34:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/perdrix">@<bdi>Perdrix</bdi></a> said in <a href="/post/763024">Odd behaviour with QPen/QColor</a>:</p>
<blockquote>
<p dir="auto">QPen pen(colour, 1.0);</p>
</blockquote>
<p dir="auto">You're not using pen anywhere as far as I can see...</p>
]]></description><link>https://forum.qt.io/post/763028</link><guid isPermaLink="true">https://forum.qt.io/post/763028</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 29 Jun 2023 12:34:31 GMT</pubDate></item><item><title><![CDATA[Reply to Odd behaviour with QPen&#x2F;QColor on Thu, 29 Jun 2023 13:04:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> Yep you're right I did miss the obvious</p>
<p dir="auto">Doh!  Slap head!</p>
<p dir="auto">painter.setPen(pen) would help a lot!</p>
]]></description><link>https://forum.qt.io/post/763036</link><guid isPermaLink="true">https://forum.qt.io/post/763036</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Thu, 29 Jun 2023 13:04:46 GMT</pubDate></item><item><title><![CDATA[Reply to Odd behaviour with QPen&#x2F;QColor on Thu, 29 Jun 2023 12:34:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/perdrix">@<bdi>Perdrix</bdi></a> said in <a href="/post/763024">Odd behaviour with QPen/QColor</a>:</p>
<blockquote>
<p dir="auto">QPen pen(colour, 1.0);</p>
</blockquote>
<p dir="auto">You're not using pen anywhere as far as I can see...</p>
]]></description><link>https://forum.qt.io/post/763028</link><guid isPermaLink="true">https://forum.qt.io/post/763028</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 29 Jun 2023 12:34:31 GMT</pubDate></item></channel></rss>