主要还是用绘画的方式实现。
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
setFixedSize(180, 70);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
ui->label->move(1, 16);
ui->label->setFixedSize(width()-2, height()-17);
}
Widget::~Widget()
{
delete ui;
}
void Widget::paintEvent(QPaintEvent *)
{
QLinearGradient linear2(rect().topLeft(), rect().bottomLeft());
linear2.setColorAt(0, QColor(247, 247, 250));
linear2.setColorAt(0.5, QColor(240, 242, 247));
linear2.setColorAt(1, QColor(233, 233, 242));
QPainter painter2(this);
painter2.setPen(Qt::black);
painter2.setBrush(linear2);
static const QPointF points[8] = {QPointF(15, 0), QPointF(15, 15), QPointF(0, 15), QPointF(0, this->height()-1), QPointF(this->width()-1, this->height()-1), QPointF(this->width()-1, 15), QPointF(30, 15), QPointF(15, 0)};
painter2.drawPolygon(points, 8);
}