替换主窗口自定义控件

This commit is contained in:
work-zym\zhangyiming 2024-12-17 11:11:53 +08:00
parent 281d41769a
commit 8dba3771c6
14 changed files with 60 additions and 34 deletions

View File

@ -1,15 +1,4 @@
QPushButton#systemsetting{border-image:url(:/image/index_bg_setting_char.png);width: 450px;
height: 500px;}
QPushButton#systemsetting:hover{border-image:url(:/image/index_bg_setting_hover.png);}
QPushButton#systemsetting:pressed{border-image:url(:/image/index_bg_setting_checked.png);}
QPushButton#egg{border-image:url(:/image/index_bg_EEG_char.png);width: 450px;
height: 500px;}
QPushButton#egg:hover{border-image:url(:/image/index_bg_EEG_hover.png);}
QPushButton#egg:pressed{border-image:url(:/image/index_bg_EEG_checked.png);}
QPushButton#dataprocess{border-image:url(:/image/index_bg_data_char.png);width: 450px;
height: 500px;}
QPushButton#dataprocess:hover{border-image:url(:/image/index_bg_data_hover.png);}
QPushButton#dataprocess:pressed{border-image:url(:/image/index_bg_data_checked.png);}
QLineEdit QLineEdit
{ {
border: 1px solid #ABCDA0; border: 1px solid #ABCDA0;

Binary file not shown.

View File

@ -63,5 +63,29 @@
<file>image/EGG_icon_newShec_hover.png</file> <file>image/EGG_icon_newShec_hover.png</file>
<file>image/EGG_icond_DeleteSh.png</file> <file>image/EGG_icond_DeleteSh.png</file>
<file>qssstyle.qss</file> <file>qssstyle.qss</file>
<file>image/acq.png</file>
<file>image/data.png</file>
<file>image/img_BEAM.png</file>
<file>image/setup.png</file>
<file>image/组件 39@1x.png</file>
<file>image/组件 40@1x.png</file>
<file>image/组件 41@1x.png</file>
<file>image/组件 42@1x.png</file>
<file>image/组件 43@1x.png</file>
<file>image/组件 44@1x.png</file>
<file>image/组件 51@1x.png</file>
<file>image/组件 52@1x.png</file>
<file>image/组件 53@1x.png</file>
<file>image/组件 54@1x.png</file>
<file>image/组件 55@1x.png</file>
<file>image/组件 56@1x.png</file>
<file>image/组件 58@1x.png</file>
<file>image/组件 59@1x.png</file>
<file>image/组件 60@1x.png</file>
<file>image/组件 61@1x.png</file>
<file>image/组件 66@1x.png</file>
<file>image/组件 67@1x.png</file>
<file>image/组件 68@1x.png</file>
<file>image/组件 69@1x.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -30,7 +30,7 @@ int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
#if 0 #if 1
// QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
//qInstallMessageHandler(MessageHandler); //qInstallMessageHandler(MessageHandler);
QTextCodec *codec = QTextCodec::codecForName("GBK"); QTextCodec *codec = QTextCodec::codecForName("GBK");
@ -43,10 +43,12 @@ int main(int argc, char *argv[])
QFont globalFont; QFont globalFont;
globalFont.setFamily("黑体"); globalFont.setFamily("黑体");
QApplication::setFont(globalFont); QApplication::setFont(globalFont);
LoadStyleFile(QApplication::applicationDirPath()+"/defaultstyle.qss"); //LoadStyleFile(QApplication::applicationDirPath()+"/defaultstyle.qss");
#endif #endif
MainBtn ll; MainBtn ll,ll2;
ll.setTxt("系统设置","EGG acquisition",""); ll.setTxt("系统设置","EGG acquisition","data");
ll.show(); ll2.setTxt("系统设置","setup","setup");
ll.show();
ll2.show();
return a.exec(); return a.exec();
} }

View File

@ -5,21 +5,27 @@
{ {
m_labTxt.setText(str); m_labTxt.setText(str);
m_labEgTxt.setText(str2) ; m_labEgTxt.setText(str2) ;
m_labImage.setText(str3); // m_labImage.setText(str3);
setObjectName("MinBtn"); setObjectName("MinBtn");
this->setStyleSheet("QFrame#MinBtn{border-image:url(:/image/index_bg_data.png);border-radius: 40px;} "); //this->setStyleSheet("QPushButton#MinBtn{border-image:url(:/image/index_bg_data.png);border-radius: 40px;} ");
m_labTxt.setStyleSheet("font-size: 60px;font-weight: 500;color:white;"); this->setStyleSheet("QPushButton{border-image:url(:/image/index_bg_setting.png);}"
m_labEgTxt.setStyleSheet("font-size: 60px;font-weight:normal;color:white;"); "QPushButton:hover{border-image:url(:/image/index_bg_setting_hover.png);}"
"QPushButton:pressed{border-image:url(:/image/index_bg_setting_checked.png);}"
);
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;");
m_labImage.setStyleSheet(QString("QLabel{border-image:url(:/image/%1.png);background-color: transparent;}").arg(str3));
} }
MainBtn::MainBtn(QWidget * parent ) MainBtn::MainBtn(QWidget * parent )
{ {
setWindowFlags(Qt::FramelessWindowHint); // 去掉边框 //setWindowFlags(Qt::FramelessWindowHint); // 去掉边框
setAttribute(Qt::WA_TranslucentBackground); // 背景透明 // setAttribute(Qt::WA_TranslucentBackground); // 背景透明
#if 1
m_labTxt.setFixedSize(QSize(240,87)); m_labTxt.setFixedSize(QSize(240,87));
//m_labEgTxt.setFixedSize(QSize(302,58));
m_labImage.setFixedSize(QSize(129,117)); m_labImage.setFixedSize(QSize(129,117));
#endif
QHBoxLayout * hlay = new QHBoxLayout; QHBoxLayout * hlay = new QHBoxLayout;
QHBoxLayout * hlay2 = new QHBoxLayout; QHBoxLayout * hlay2 = new QHBoxLayout;
QHBoxLayout * hlay3 = new QHBoxLayout; QHBoxLayout * hlay3 = new QHBoxLayout;
@ -38,14 +44,14 @@ MainBtn::MainBtn(QWidget * parent )
vlay->addLayout(hlay3); vlay->addLayout(hlay3);
vlay->setSpacing(0); vlay->setSpacing(0);
vlay->setContentsMargins(45,45,45,45); vlay->setContentsMargins(45,45,45,45);
//setFixedSize(QSize(450,500)); setFixedSize(QSize(450,500));
setLayout(vlay); setLayout(vlay);
} }
MainBtn::~MainBtn() MainBtn::~MainBtn()
{ {
} }
#if 0
void MainBtn::mouseReleaseEvent(QMouseEvent * ev) void MainBtn::mouseReleaseEvent(QMouseEvent * ev)
{ {
@ -57,3 +63,4 @@ void MainBtn::paintEvent(QPaintEvent* event)
QPainter p(this); QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
} }
#endif

View File

@ -6,18 +6,18 @@
#include <QStyleOption> #include <QStyleOption>
#include <QPaintEvent> #include <QPaintEvent>
#include <QPainter> #include <QPainter>
class MainBtn:public QFrame class MainBtn:public QPushButton
{ {
Q_OBJECT Q_OBJECT
public: public:
MainBtn(QWidget * parent =NULL); MainBtn(QWidget * parent =NULL);
~MainBtn(); ~MainBtn();
void setTxt(QString str,QString str2,QString str3); void setTxt(QString str,QString str2,QString str3);
void paintEvent(QPaintEvent* event); // void paintEvent(QPaintEvent* event);
signals: signals:
void clicked(); // void clicked();
protected: protected:
virtual void mouseReleaseEvent(QMouseEvent * ev); //virtual void mouseReleaseEvent(QMouseEvent * ev);
private: private:
QLabel m_labTxt; QLabel m_labTxt;
QLabel m_labEgTxt; QLabel m_labEgTxt;

View File

@ -27,6 +27,9 @@ void MainWindow::init()
m_CompanyDes.setFont(font); m_CompanyDes.setFont(font);
m_CompanyDes.setStyleSheet("color:Gray;"); m_CompanyDes.setStyleSheet("color:Gray;");
m_btnDataProcess.setTxt("数据处理","Data processing","data");
m_btnEEG.setTxt("脑电采集","EGG acquisition","acq");
m_btnSystemSetting.setTxt("系统设置","Set up","setup");
} }

View File

@ -9,6 +9,7 @@
#include <QLineEdit> #include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include "titlewidget.h" #include "titlewidget.h"
#include "mainbtn.h"
class MainWindow: public QWidget class MainWindow: public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -26,11 +27,11 @@ signals:
private: private:
TitleWidget m_titleWidget; TitleWidget m_titleWidget;
//系统设置 //系统设置
QPushButton m_btnSystemSetting; MainBtn m_btnSystemSetting;
//脑电采集Electroencephalography //脑电采集Electroencephalography
QPushButton m_btnEEG; MainBtn m_btnEEG;
//数据处理Datarocessing //数据处理Datarocessing
QPushButton m_btnDataProcess; MainBtn m_btnDataProcess;
//河南翔宇医疗设备股份有限公司 //河南翔宇医疗设备股份有限公司
QLabel m_CompanyDes; QLabel m_CompanyDes;
}; };