74 lines
2.2 KiB
C++
Raw Normal View History

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) ;
2024-12-17 11:11:53 +08:00
// m_labImage.setText(str3);
2024-12-17 15:48:19 +08:00
2024-12-17 11:11:53 +08:00
m_labImage.setStyleSheet(QString("QLabel{border-image:url(:/image/%1.png);background-color: transparent;}").arg(str3));
2024-12-16 17:38:25 +08:00
}
2024-12-17 15:48:19 +08:00
MainBtn::MainBtn(QPushButton * parent ):QPushButton (parent)
2024-12-16 17:38:25 +08:00
{
2024-12-17 15:48:19 +08:00
setObjectName("MainBtn");
m_labTxt.setObjectName("MainTxt");
m_labEgTxt.setObjectName("MainTxtEn");
#if 0
this->setStyleSheet("QPushButton{border-image:url(:/image/index_bg_setting.png);}"
"QPushButton:hover{border-image:url(:/image/index_bg_setting_hover.png);}"
"QPushButton:pressed{border-image:url(:/image/index_bg_setting_checked.png);}" );
2024-12-17 15:48:19 +08:00
m_labTxt.setStyleSheet("font-size: 60px;font-weight: 500;color:white;background-color:transparent;");
m_labEgTxt.setStyleSheet("font-size: 60px;font-weight:normal;color:white;background-color:transparent;");
2024-12-17 15:48:19 +08:00
#endif
m_labTxt.setStyleSheet("font-size: 60px;font-weight: 500;color:white;background-color:transparent;");
m_labEgTxt.setStyleSheet("font-size: 60px;font-weight:normal;color:white;background-color:transparent;");
2024-12-17 15:48:19 +08:00
2024-12-17 11:11:53 +08:00
#if 1
2024-12-16 17:38:25 +08:00
m_labTxt.setFixedSize(QSize(240,87));
2024-12-17 11:11:53 +08:00
m_labImage.setFixedSize(QSize(129,117));
2024-12-16 17:38:25 +08:00
2024-12-17 11:11:53 +08:00
#endif
2024-12-16 17:38:25 +08:00
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);
2024-12-17 11:11:53 +08:00
setFixedSize(QSize(450,500));
2024-12-16 17:38:25 +08:00
setLayout(vlay);
}
MainBtn::~MainBtn()
{
}
2024-12-17 11:11:53 +08:00
#if 0
2024-12-16 17:38:25 +08:00
void MainBtn::mouseReleaseEvent(QMouseEvent * ev)
{
}
void MainBtn::paintEvent(QPaintEvent* event)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
2024-12-17 11:11:53 +08:00
#endif