How to make bottom right & bottom left corner round of the QWidget
Hi all
I want to make my widgets bottom right and bottom left corner round without using QPaint
regards
merry
Re: How to make bottom right & bottom left corner round of the QWidget
Re: How to make bottom right & bottom left corner round of the QWidget
Hi Sabeesh
Thanx 4 sending me the link but this link is not opening
regards
merry:)
Re: How to make bottom right & bottom left corner round of the QWidget
Search the forum, please. Hint: search for "rounded corners".
Re: How to make bottom right & bottom left corner round of the QWidget
Re: How to make bottom right & bottom left corner round of the QWidget
Or you can use stylesheets.
Re: How to make bottom right & bottom left corner round of the QWidget
Thanx for the replies
When I use this
Code:
static QRegion roundedRect
(const QRect
& rect,
int r
) {
// middle and borders
region += rect.adjusted(r, 0, -r, 0);
region += rect.adjusted(0, r, 0, -r);
// top left
// top right
corner.moveTopRight(rect.topRight());
// bottom left
corner.moveBottomLeft(rect.bottomLeft());
// bottom right
corner.moveBottomRight(rect.bottomRight());
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
Re: How to make bottom right & bottom left corner round of the QWidget
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)