2024-12-16 17:38:25 +08:00
|
|
|
#include "mainbtn.h"
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
void MainBtn::setTxt(QString str,QString str2,QString str3)
|
|
|
|
{
|
|
|
|
m_labTxt.setText(str);
|
|
|
|
m_labEgTxt.setText(str2) ;
|
|
|
|
m_labImage.setText(str3);
|
|
|
|
setObjectName("MinBtn");
|
|
|
|
this->setStyleSheet("QFrame#MinBtn{border-image:url(:/image/index_bg_data.png);border-radius: 40px;} ");
|
|
|
|
m_labTxt.setStyleSheet("font-size: 60px;font-weight: 500;color:white;");
|
|
|
|
m_labEgTxt.setStyleSheet("font-size: 60px;font-weight:normal;color:white;");
|
|
|
|
}
|
|
|
|
MainBtn::MainBtn(QWidget * parent )
|
|
|
|
{
|
2024-12-16 17:43:50 +08:00
|
|
|
setWindowFlags(Qt::FramelessWindowHint); // 去掉边框
|
|
|
|
setAttribute(Qt::WA_TranslucentBackground); // 背景透明
|
2024-12-16 17:38:25 +08:00
|
|
|
m_labTxt.setFixedSize(QSize(240,87));
|
|
|
|
//m_labEgTxt.setFixedSize(QSize(302,58));
|
|
|
|
m_labImage.setFixedSize(QSize(129,117));
|
|
|
|
|
|
|
|
|
|
|
|
QHBoxLayout * hlay = new QHBoxLayout;
|
|
|
|
QHBoxLayout * hlay2 = new QHBoxLayout;
|
|
|
|
QHBoxLayout * hlay3 = new QHBoxLayout;
|
|
|
|
hlay->addWidget(&m_labTxt);
|
|
|
|
hlay->addStretch();
|
|
|
|
hlay2->addWidget(&m_labEgTxt);
|
|
|
|
hlay2->addStretch();
|
|
|
|
hlay3->addStretch();
|
|
|
|
hlay3->addWidget(&m_labImage);
|
|
|
|
|
|
|
|
|
|
|
|
QVBoxLayout * vlay = new QVBoxLayout;
|
|
|
|
vlay->addLayout(hlay);
|
|
|
|
vlay->addLayout(hlay2);
|
|
|
|
vlay->addSpacing(143);
|
|
|
|
vlay->addLayout(hlay3);
|
|
|
|
vlay->setSpacing(0);
|
|
|
|
vlay->setContentsMargins(45,45,45,45);
|
|
|
|
//setFixedSize(QSize(450,500));
|
|
|
|
setLayout(vlay);
|
|
|
|
}
|
|
|
|
MainBtn::~MainBtn()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainBtn::mouseReleaseEvent(QMouseEvent * ev)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2024-12-16 17:43:50 +08:00
|
|
|
void MainBtn::paintEvent(QPaintEvent* event)
|
|
|
|
{
|
|
|
|
QStyleOption opt;
|
|
|
|
opt.init(this);
|
|
|
|
QPainter p(this);
|
|
|
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
|
|
|
}
|