1. 程式人生 > >Qt:圓形頭像

Qt:圓形頭像


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);