void Widget::setRoundedCorners(int radius_tl, int radius_tr, int radius_bl, int radius_br) {
// top left
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);
}
void Widget::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);
}
To copy to clipboard, switch view to plain text mode
Bookmarks