改进代码
parent
8b37cfa9bf
commit
f0abf6588e
File diff suppressed because it is too large
Load Diff
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<widget class="FramelessDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -210,6 +210,14 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>FramelessDialog</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>framelessdialog.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -6,14 +6,22 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>207</width>
|
||||
<height>59</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
|
@ -212,6 +220,14 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>FramelessMainWindow</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>framelessmainwindow.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Widget</class>
|
||||
<widget class="QWidget" name="Widget">
|
||||
<widget class="FramelessWidget" name="Widget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -210,6 +210,14 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>FramelessWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>framelesswidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue