Qt:圆形头像

Qt:圆形头像_第1张图片

QPixmap pixmapa(avantar);
QPixmap pixmap(80,80);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
QPainterPath path;
path.addEllipse(0, 0, 80, 80);
painter.setClipPath(path);
painter.drawPixmap(0, 0, 80, 80, pixmapa);
ui->labelAvantar->setPixmap(pixmap);

你可能感兴趣的:(Qt)