#include "framewindow.h" #include <QHBoxLayout> #include <QVBoxLayout> #include <QGridLayout> #include <QDebug> FrameWindow::FrameWindow(QWidget * parent ) { init(); initLay(); initConnect(); setWindowFlags(Qt::FramelessWindowHint); // 去掉边框 setAttribute(Qt::WA_TranslucentBackground); // 背景透明 } FrameWindow::~FrameWindow() { } void FrameWindow::init() { m_stackWidget.addWidget(&m_MainWindow); m_stackWidget.setCurrentWidget(&m_MainWindow); setWindowTitle(" "); setObjectName("FrameWindow"); this->setStyleSheet("QWidget{background-color:#ffffff;}"); } void FrameWindow::initLay() { QVBoxLayout * vlay = new QVBoxLayout; vlay->addWidget(&m_stackWidget); vlay->setContentsMargins(0,0,0,0); setLayout(vlay); } bool FrameWindow::initConnect() { bool bCon = true; bCon = connect(&m_MainWindow,SIGNAL(SigClicked(QString)),this,SLOT(slotClickedChanged(QString))); if(!bCon) { qDebug()<<"connect failed"<<endl; } bCon = connect(&m_SystemSetting,SIGNAL(SigClicked(QString)),this,SLOT(slotClickedChanged(QString))); if(!bCon) { qDebug()<<"connect failed"<<endl; } bCon = connect(&m_Egg,SIGNAL(SigClicked(QString)),this,SLOT(slotClickedChanged(QString))); if(!bCon) { qDebug()<<"connect failed"<<endl; } bCon = connect(&m_DataProcess,SIGNAL(SigClicked(QString)),this,SLOT(slotClickedChanged(QString))); if(!bCon) { qDebug()<<"connect failed"<<endl; } return bCon; } void FrameWindow::slotClickedChanged(QString btnName) { qDebug()<<btnName <<endl; if(btnName.compare("EEG") == 0) { m_stackWidget.addWidget(&m_Egg); m_stackWidget.setCurrentWidget(&m_Egg); } else if(btnName.compare("DataProcess") == 0) { m_stackWidget.addWidget(&m_DataProcess); m_stackWidget.setCurrentWidget(&m_DataProcess); } else if(btnName.compare("SystemSetting") == 0) { m_stackWidget.addWidget(&m_SystemSetting); m_stackWidget.setCurrentWidget(&m_SystemSetting); } else { m_stackWidget.addWidget(&m_MainWindow); m_stackWidget.setCurrentWidget(&m_MainWindow); } }