<?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[Perfectly rounding your widget]]></title><description><![CDATA[<p dir="auto">Hello, everyone,<br />
as the title says, I have an algorithm that allows you to round a widget (the 4 corners), but it doesn't perfectly round a widget because if you test this algorithm you will notice that the curve is not really round, here is an image to be a little clear:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/b4d2777e-483d-445e-989e-6d8a0c1db86a.PNG" alt="0_1548436704998_Capture2.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">please do not take into account what is written but rather take into account the rounded corners of the widget, you will notice that it is not perfectly rounded.<br />
my problem is that I want your help on my algorithm to make my widgets perfectly rounded.<br />
here is my code (algorithm):</p>
<pre><code>void setRoundedCorners(int radius_tl, int radius_tr, int radius_bl, int radius_br) {
    QRegion region(0, 0, width(), height(), QRegion::Rectangle);

    // top left
    QRegion round (0, 0, 2*radius_tl, 2*radius_tl, QRegion::Ellipse);
    QRegion corner(0, 0, radius_tl, radius_tl, QRegion::Rectangle);
    region = region.subtracted(corner.subtracted(round));

    // top right
    round = QRegion(width()-2*radius_tr, 0, 2*radius_tr, 2*radius_tr, QRegion::Ellipse);
    corner = QRegion(width()-radius_tr, 0, radius_tr, radius_tr, QRegion::Rectangle);
    region = region.subtracted(corner.subtracted(round));

    // bottom right
    round = QRegion(width()-2*radius_br, height()-2*radius_br, 2*radius_br, 2*radius_br, QRegion::Ellipse);
    corner = QRegion(width()-radius_br, height()-radius_br, radius_br, radius_br, QRegion::Rectangle);
    region = region.subtracted(corner.subtracted(round));

    // bottom left
    round = QRegion(0, height()-2*radius_bl, 2*radius_bl, 2*radius_bl, QRegion::Ellipse);
    corner = QRegion(0, height()-radius_bl, radius_bl, radius_bl, QRegion::Rectangle);
    region = region.subtracted(corner.subtracted(round));

    setMask(region);
}
</code></pre>
<p dir="auto">thank you in advance for your help</p>
]]></description><link>https://forum.qt.io/topic/98951/perfectly-rounding-your-widget</link><generator>RSS for Node</generator><lastBuildDate>Sun, 25 Oct 2026 13:51:20 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/98951.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Jan 2019 17:36:23 GMT</pubDate><ttl>60</ttl></channel></rss>