From e1065dd36139fbd5cef7046d0520d2d775560b14 Mon Sep 17 00:00:00 2001 From: feiyangqingyun Date: Sun, 19 Sep 2021 17:37:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framelesswidget/framelessform/dialog.ui | 14 ++++-- framelesswidget/framelessform/mainwindow.ui | 20 ++++++++- framelesswidget/framelessform/widget.ui | 14 ++++-- framelesswidget/frmframelesswidget.cpp | 48 +++++++++++---------- framelesswidget/frmframelesswidget.h | 9 +--- lunarcalendarwidget/lunarcalendarwidget.cpp | 10 +++-- lunarcalendarwidget/lunarcalendarwidget.h | 4 +- 7 files changed, 76 insertions(+), 43 deletions(-) diff --git a/framelesswidget/framelessform/dialog.ui b/framelesswidget/framelessform/dialog.ui index 6c7df10..574cc27 100644 --- a/framelesswidget/framelessform/dialog.ui +++ b/framelesswidget/framelessform/dialog.ui @@ -1,13 +1,13 @@ Dialog - + 0 0 - 400 - 300 + 800 + 600 @@ -210,6 +210,14 @@ + + + FramelessDialog + QWidget +
framelessdialog.h
+ 1 +
+
diff --git a/framelesswidget/framelessform/mainwindow.ui b/framelesswidget/framelessform/mainwindow.ui index b4b93c1..29516ab 100644 --- a/framelesswidget/framelessform/mainwindow.ui +++ b/framelesswidget/framelessform/mainwindow.ui @@ -6,14 +6,22 @@ 0 0 - 400 - 300 + 800 + 600 MainWindow + + + 0 + 0 + 207 + 59 + + 0 @@ -212,6 +220,14 @@ + + + FramelessMainWindow + QWidget +
framelessmainwindow.h
+ 1 +
+
diff --git a/framelesswidget/framelessform/widget.ui b/framelesswidget/framelessform/widget.ui index ebe649d..52428dc 100644 --- a/framelesswidget/framelessform/widget.ui +++ b/framelesswidget/framelessform/widget.ui @@ -1,13 +1,13 @@ Widget - + 0 0 - 400 - 300 + 800 + 600 @@ -210,6 +210,14 @@ + + + FramelessWidget + QWidget +
framelesswidget.h
+ 1 +
+
diff --git a/framelesswidget/frmframelesswidget.cpp b/framelesswidget/frmframelesswidget.cpp index 46d69d4..7848adc 100644 --- a/framelesswidget/frmframelesswidget.cpp +++ b/framelesswidget/frmframelesswidget.cpp @@ -4,16 +4,19 @@ #include "ui_frmframelesswidget.h" #include "qpushbutton.h" #include "qcheckbox.h" +#include "qdebug.h" #include "framelesswidget2.h" + +#ifndef Q_CC_MSVC #include "framelessform/dialog.h" #include "framelessform/widget.h" #include "framelessform/mainwindow.h" +#endif frmFramelessWidget::frmFramelessWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmFramelessWidget) { ui->setupUi(this); - widget = 0; - frameless = 0; + this->initForm(); } frmFramelessWidget::~frmFramelessWidget() @@ -21,9 +24,14 @@ frmFramelessWidget::~frmFramelessWidget() delete ui; } -void frmFramelessWidget::closeEvent(QCloseEvent *) +void frmFramelessWidget::initForm() { - exit(0); + widget = 0; + frameless = 0; + + connect(ui->btnDialog, SIGNAL(clicked(bool)), this, SLOT(buttonClicked())); + connect(ui->btnWidget, SIGNAL(clicked(bool)), this, SLOT(buttonClicked())); + connect(ui->btnMainWindow, SIGNAL(clicked(bool)), this, SLOT(buttonClicked())); } void frmFramelessWidget::initWidget(QWidget *w) @@ -84,23 +92,19 @@ void frmFramelessWidget::stateChanged2(int arg1) } } -void frmFramelessWidget::on_btnDialog_clicked() +void frmFramelessWidget::buttonClicked() { - Dialog dialog; - dialog.resize(800, 600); - dialog.exec(); -} - -void frmFramelessWidget::on_btnWidget_clicked() -{ - Widget *widget = new Widget; - widget->resize(800, 600); - widget->show(); -} - -void frmFramelessWidget::on_btnMainWindow_clicked() -{ - MainWindow *window = new MainWindow; - window->resize(800, 600); - window->show(); +#ifndef Q_CC_MSVC + QString objName = sender()->objectName(); + if (objName == "btnDialog") { + Dialog dialog; + dialog.exec(); + } else if (objName == "btnWidget") { + Widget *widget = new Widget; + widget->show(); + } else if (objName == "btnMainWindow") { + MainWindow *window = new MainWindow; + window->show(); + } +#endif } diff --git a/framelesswidget/frmframelesswidget.h b/framelesswidget/frmframelesswidget.h index f089126..ffd9660 100644 --- a/framelesswidget/frmframelesswidget.h +++ b/framelesswidget/frmframelesswidget.h @@ -16,23 +16,18 @@ public: explicit frmFramelessWidget(QWidget *parent = 0); ~frmFramelessWidget(); -protected: - void closeEvent(QCloseEvent *); - private: Ui::frmFramelessWidget *ui; QWidget *widget; FramelessWidget2 *frameless; private slots: + void initForm(); void initWidget(QWidget *w); void on_pushButton_clicked(); void stateChanged1(int arg1); void stateChanged2(int arg1); - - void on_btnDialog_clicked(); - void on_btnWidget_clicked(); - void on_btnMainWindow_clicked(); + void buttonClicked(); }; #endif // FRMFRAMELESSWIDGET_H diff --git a/lunarcalendarwidget/lunarcalendarwidget.cpp b/lunarcalendarwidget/lunarcalendarwidget.cpp index 147b7cd..7d38de2 100644 --- a/lunarcalendarwidget/lunarcalendarwidget.cpp +++ b/lunarcalendarwidget/lunarcalendarwidget.cpp @@ -203,8 +203,8 @@ void LunarCalendarWidget::initWidget() connect(btnPrevMonth, SIGNAL(clicked(bool)), this, SLOT(showPreviousMonth())); connect(btnNextMonth, SIGNAL(clicked(bool)), this, SLOT(showNextMonth())); connect(btnToday, SIGNAL(clicked(bool)), this, SLOT(showToday())); - connect(cboxYear, SIGNAL(currentIndexChanged(QString)), this, SLOT(yearChanged(QString))); - connect(cboxMonth, SIGNAL(currentIndexChanged(QString)), this, SLOT(monthChanged(QString))); + connect(cboxYear, SIGNAL(currentIndexChanged(int)), this, SLOT(yearChanged(int))); + connect(cboxMonth, SIGNAL(currentIndexChanged(int)), this, SLOT(monthChanged(int))); } void LunarCalendarWidget::initStyle() @@ -351,26 +351,28 @@ void LunarCalendarWidget::initDate() dayChanged(this->date); } -void LunarCalendarWidget::yearChanged(const QString &arg1) +void LunarCalendarWidget::yearChanged(int) { //如果是单击按钮切换的日期变动则不需要触发 if (btnClick) { return; } + QString arg1 = cboxYear->currentText(); int year = arg1.mid(0, arg1.length() - 1).toInt(); int month = date.month(); int day = date.day(); dateChanged(year, month, day); } -void LunarCalendarWidget::monthChanged(const QString &arg1) +void LunarCalendarWidget::monthChanged(int) { //如果是单击按钮切换的日期变动则不需要触发 if (btnClick) { return; } + QString arg1 = cboxMonth->currentText(); int year = date.year(); int month = arg1.mid(0, arg1.length() - 1).toInt(); int day = date.day(); diff --git a/lunarcalendarwidget/lunarcalendarwidget.h b/lunarcalendarwidget/lunarcalendarwidget.h index 753365a..58e7bfe 100644 --- a/lunarcalendarwidget/lunarcalendarwidget.h +++ b/lunarcalendarwidget/lunarcalendarwidget.h @@ -132,8 +132,8 @@ private slots: void initWidget(); void initStyle(); void initDate(); - void yearChanged(const QString &arg1); - void monthChanged(const QString &arg1); + void yearChanged(int); + void monthChanged(int); void clicked(const QDate &date, const LunarCalendarItem::DayType &dayType); void dayChanged(const QDate &date); void dateChanged(int year, int month, int day);