-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiptitle.cpp
More file actions
37 lines (32 loc) · 1.03 KB
/
Copy pathtiptitle.cpp
File metadata and controls
37 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "tiptitle.h"
#include <QHBoxLayout>
#include <QPainter>
#include <QLinearGradient>//线性渐变
TipTitle::TipTitle(QWidget *parent) :
QWidget(parent)
{
titleLabel=new QLabel();
btnClose=new TipImgPushBtn("://img/close.png");
btnClose->setToolTip("关闭");
connect(btnClose,SIGNAL(clicked()),this,SIGNAL(closeTitle()));
QHBoxLayout *layout=new QHBoxLayout;
layout->addWidget(titleLabel,0,Qt::AlignLeft);
layout->addStretch();
layout->addWidget(btnClose,0,Qt::AlignRight);
layout->setMargin(0);
setLayout(layout);
setFixedHeight(22);
}
void TipTitle::setTitleText(QString title){
titleLabel->setText(title);
}
void TipTitle::paintEvent(QPaintEvent *){
QLinearGradient linear(rect().topLeft(),rect().bottomRight());
linear.setColorAt(0,QColor(227,207,87));
linear.setColorAt(0.5,QColor(245,222,179));
linear.setColorAt(1,QColor(189,252,201));
QPainter painter(this);
painter.setBrush(QBrush(linear));
painter.setPen(Qt::NoPen);
painter.drawRect(rect());
}