QPixmap QHRotateWidget::round(const QPixmap &src, int radius)
{
if (src.isNull())
{
return QPixmap();
}
QBitmap mask(src.size());
QPainter painter(&mask);
painter.setRenderHint(QPainter::Antialiasing);
painter.fillRect(mask.rect(), Qt::white);
painter.setBrush(Qt::black);
painter.drawRoundedRect(mask.rect(), radius, radius);
QPixmap image = src.copy();
image.setMask(mask);
return image;
}
原文链接:https://blog.csdn.net/caoshangpa/article/details/78563274