View Full Version : How to make bottom right & bottom left corner round of the QWidget
merry
15th November 2007, 06:20
Hi all
I want to make my widgets bottom right and bottom left corner round without using QPaint
regards
merry
sabeesh
15th November 2007, 08:51
Hi.
Please search this link http://www.qtcentre.org/forum/f-qt-p...ners-3205.html
:)
merry
15th November 2007, 09:01
Hi Sabeesh
Thanx 4 sending me the link but this link is not opening
regards
merry:)
jpn
15th November 2007, 09:29
Search the forum, please. Hint: search for "rounded corners".
sabeesh
15th November 2007, 11:09
Hi,
Please try this.
http://www.qtcentre.org/forum/f-qt-programming-2/t-toplevel-widget-with-rounded-corners-3205.html
wysota
15th November 2007, 11:22
Or you can use stylesheets.
merry
15th November 2007, 11:32
Thanx for the replies
When I use this
static QRegion roundedRect(const QRect& rect, int r)
{
QRegion region;
// middle and borders
region += rect.adjusted(r, 0, -r, 0);
region += rect.adjusted(0, r, 0, -r);
// top left
QRect corner(rect.topLeft(), QSize(r*2, r*2));
region += QRegion(corner, QRegion::Ellipse);
// top right
corner.moveTopRight(rect.topRight());
region += QRegion(corner, QRegion::Ellipse);
// bottom left
corner.moveBottomLeft(rect.bottomLeft());
region += QRegion(corner, QRegion::Ellipse);
// bottom right
corner.moveBottomRight(rect.bottomRight());
region += QRegion(corner, QRegion::Ellipse);
return region;
}
someWidget->setMask(roundedRect(someWidget->rect(), 20));
All the corners of the widget get rounded , and I want only the bottom left and bottom right corners
If in the above code ,I wont make calculations for the top left and top right corners then
some part of the top left and top right corners is subtracted from the widget.
regards
merry
pherthyl
15th November 2007, 17:19
You're creating a mask by putting together a combination of quarter circles and rectangles. Just think about how to build that. You'll need one rectangle for the widget minus the bottom edge, so width() and height()-r. Then you'll want the bottom left and right corners as shown above, and the bottom edge between the corners (width()-2*r and height is r)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.