<?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[Trying to Draw QRubberBand but QRubberBand not displayed properly]]></title><description><![CDATA[<p dir="auto">Qt version 5.8.0<br />
Windows 7</p>
<p dir="auto">I am drawing a QRubberBand on a QLable, also coloring the QRubberBand Border as Yellow but the whole rectangle is filled with Yellow color.</p>
<p dir="auto">I only want the QRubberBand borders to be yellow and not the inside of the QRubberBand<br />
<img src="/uploads/files/1495717800600-yellow_rectangle-resized.png" alt="0_1495717800349_Yellow_rectangle.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/topic/79612/trying-to-draw-qrubberband-but-qrubberband-not-displayed-properly</link><generator>RSS for Node</generator><lastBuildDate>Mon, 18 May 2026 18:33:47 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/79612.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 25 May 2017 13:12:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Trying to Draw QRubberBand but QRubberBand not displayed properly on Fri, 26 May 2017 09:00:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vinod-kuntoji">@<bdi>Vinod-Kuntoji</bdi></a></p>
<p dir="auto">No not working ,<br />
rubberBand-&gt;setPalette(Qt::transparent); removes the color from borders also..</p>
]]></description><link>https://forum.qt.io/post/395614</link><guid isPermaLink="true">https://forum.qt.io/post/395614</guid><dc:creator><![CDATA[Swapnil_Shelke]]></dc:creator><pubDate>Fri, 26 May 2017 09:00:31 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to Draw QRubberBand but QRubberBand not displayed properly on Fri, 26 May 2017 05:57:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/swapnil_shelke">@<bdi>Swapnil_Shelke</bdi></a> ,<br />
OK. try this,<br />
rubberBand-&gt;setPalette(Qt::transparent);</p>
]]></description><link>https://forum.qt.io/post/395574</link><guid isPermaLink="true">https://forum.qt.io/post/395574</guid><dc:creator><![CDATA[Vinod Kuntoji]]></dc:creator><pubDate>Fri, 26 May 2017 05:57:07 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to Draw QRubberBand but QRubberBand not displayed properly on Fri, 26 May 2017 05:48:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vinod-kuntoji">@<bdi>Vinod-Kuntoji</bdi></a></p>
<p dir="auto">not getting setPen in QPalette</p>
]]></description><link>https://forum.qt.io/post/395573</link><guid isPermaLink="true">https://forum.qt.io/post/395573</guid><dc:creator><![CDATA[Swapnil_Shelke]]></dc:creator><pubDate>Fri, 26 May 2017 05:48:55 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to Draw QRubberBand but QRubberBand not displayed properly on Fri, 26 May 2017 05:17:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/swapnil_shelke">@<bdi>Swapnil_Shelke</bdi></a> ,</p>
<p dir="auto">You should not use setBrush, it will fill your rectangle with yellow color, Use setPen with yellow color, it will set the yellow border.</p>
]]></description><link>https://forum.qt.io/post/395570</link><guid isPermaLink="true">https://forum.qt.io/post/395570</guid><dc:creator><![CDATA[Vinod Kuntoji]]></dc:creator><pubDate>Fri, 26 May 2017 05:17:08 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to Draw QRubberBand but QRubberBand not displayed properly on Fri, 26 May 2017 05:08:15 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
The docs says</p>
<p dir="auto">Rectangle A QRubberBand can represent a rectangle. Some<br />
styles will interpret this as a filled (often<br />
semi-transparent) rectangle, or a rectangular<br />
outline.</p>
<p dir="auto">It's also filled on windows 10 so I guess it's by design / also affected by the platform style.</p>
<p dir="auto">It draws with QStyle::CE_RubberBand<br />
so you could override with <a href="http://doc.qt.io/qt-5/qproxystyle.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qproxystyle.html</a></p>
<pre><code>class MRubberStyle : public QProxyStyle {
 public:
  MRubberStyle() : QProxyStyle() {}
  ~MRubberStyle() {}

  virtual void drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget = 0) const {
    switch(element) {
      case CE_RubberBand:
        // draw as u want
        return;
      default:
        QApplication::style()-&gt;drawControl(element, option, painter, widget);
    }
  }
};
...
 app.setStyle( new MRubberStyle );

</code></pre>
]]></description><link>https://forum.qt.io/post/395566</link><guid isPermaLink="true">https://forum.qt.io/post/395566</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Fri, 26 May 2017 05:08:15 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to Draw QRubberBand but QRubberBand not displayed properly on Fri, 26 May 2017 04:35:14 GMT]]></title><description><![CDATA[<p dir="auto">the following is the code i am using</p>
<p dir="auto">dummyband = new QRubberBand(QRubberBand::Rectangle, this);</p>
<pre><code>QPalette palette;
//palette.setBrush(QPalette::Foreground, QBrush(color));
//palette.setBrush(QPalette::Base, QBrush(color));
palette.setBrush(QPalette::Highlight, QBrush(yellow));
dummyband-&gt;setPalette(palette);
dummyband-&gt;setGeometry(QRect(topLeft, bottomRight));
dummyband-&gt;show();
</code></pre>
]]></description><link>https://forum.qt.io/post/395561</link><guid isPermaLink="true">https://forum.qt.io/post/395561</guid><dc:creator><![CDATA[Swapnil_Shelke]]></dc:creator><pubDate>Fri, 26 May 2017 04:35:14 GMT</pubDate></item><item><title><![CDATA[Reply to Trying to Draw QRubberBand but QRubberBand not displayed properly on Thu, 25 May 2017 13:23:50 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Could you show your code that sets the color to Yellow?</p>
<p dir="auto">Eddy</p>
]]></description><link>https://forum.qt.io/post/395459</link><guid isPermaLink="true">https://forum.qt.io/post/395459</guid><dc:creator><![CDATA[Eddy]]></dc:creator><pubDate>Thu, 25 May 2017 13:23:50 GMT</pubDate></item></channel></rss>