Qt 自定义按钮
QBitmap bmp(this->size());
bmp.fill();
QPainter pai(&bmp);
pai.setPen(Qt::NoPen);
pai.setBrush(Qt::black);
QPoint polygon[4] =
{
{this->width() / 3, 0},
{this->width(), 0},
{this->width() - this->width() / 3, this->height()},
{0, this->height()}
};
pai.drawPolygon(polygon, 4);
this->setMask(bmp);
name_lab = new QLabel(QString(" %1 ").arg("窦的的"), this);
name_lab->setFixedHeight(35);
name_lab->setFixedWidth(this->width() - this->width() / 4);
name_lab->setStyleSheet("font-size:30px; background-color:rgba(244,164,96,150)");
name_lab->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
name_lab->move(0, this->height() - name_lab->height());
QLabel *pix_lab = new QLabel(this);
pix_lab->resize(this->width(), this->height() - name_lab->height());
pix_lab->setPixmap(QPixmap(QString(":/HeadPhoto/head%1.jpg").arg(rand() % 10 + 1)).scaled(pix_lab->size()));