改进代码
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>Dialog</class>
|
<class>Dialog</class>
|
||||||
<widget class="QDialog" name="Dialog">
|
<widget class="FramelessDialog" name="Dialog">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>800</width>
|
||||||
<height>300</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -210,6 +210,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>FramelessDialog</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>framelessdialog.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -6,14 +6,22 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>800</width>
|
||||||
<height>300</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<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">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@@ -212,6 +220,14 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>FramelessMainWindow</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>framelessmainwindow.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>Widget</class>
|
<class>Widget</class>
|
||||||
<widget class="QWidget" name="Widget">
|
<widget class="FramelessWidget" name="Widget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>800</width>
|
||||||
<height>300</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -210,6 +210,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>FramelessWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>framelesswidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
@@ -4,16 +4,19 @@
|
|||||||
#include "ui_frmframelesswidget.h"
|
#include "ui_frmframelesswidget.h"
|
||||||
#include "qpushbutton.h"
|
#include "qpushbutton.h"
|
||||||
#include "qcheckbox.h"
|
#include "qcheckbox.h"
|
||||||
|
#include "qdebug.h"
|
||||||
#include "framelesswidget2.h"
|
#include "framelesswidget2.h"
|
||||||
|
|
||||||
|
#ifndef Q_CC_MSVC
|
||||||
#include "framelessform/dialog.h"
|
#include "framelessform/dialog.h"
|
||||||
#include "framelessform/widget.h"
|
#include "framelessform/widget.h"
|
||||||
#include "framelessform/mainwindow.h"
|
#include "framelessform/mainwindow.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
frmFramelessWidget::frmFramelessWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmFramelessWidget)
|
frmFramelessWidget::frmFramelessWidget(QWidget *parent) : QWidget(parent), ui(new Ui::frmFramelessWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
widget = 0;
|
this->initForm();
|
||||||
frameless = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frmFramelessWidget::~frmFramelessWidget()
|
frmFramelessWidget::~frmFramelessWidget()
|
||||||
@@ -21,9 +24,14 @@ frmFramelessWidget::~frmFramelessWidget()
|
|||||||
delete ui;
|
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)
|
void frmFramelessWidget::initWidget(QWidget *w)
|
||||||
@@ -84,23 +92,19 @@ void frmFramelessWidget::stateChanged2(int arg1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void frmFramelessWidget::on_btnDialog_clicked()
|
void frmFramelessWidget::buttonClicked()
|
||||||
{
|
{
|
||||||
|
#ifndef Q_CC_MSVC
|
||||||
|
QString objName = sender()->objectName();
|
||||||
|
if (objName == "btnDialog") {
|
||||||
Dialog dialog;
|
Dialog dialog;
|
||||||
dialog.resize(800, 600);
|
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
} else if (objName == "btnWidget") {
|
||||||
|
|
||||||
void frmFramelessWidget::on_btnWidget_clicked()
|
|
||||||
{
|
|
||||||
Widget *widget = new Widget;
|
Widget *widget = new Widget;
|
||||||
widget->resize(800, 600);
|
|
||||||
widget->show();
|
widget->show();
|
||||||
}
|
} else if (objName == "btnMainWindow") {
|
||||||
|
|
||||||
void frmFramelessWidget::on_btnMainWindow_clicked()
|
|
||||||
{
|
|
||||||
MainWindow *window = new MainWindow;
|
MainWindow *window = new MainWindow;
|
||||||
window->resize(800, 600);
|
|
||||||
window->show();
|
window->show();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,23 +16,18 @@ public:
|
|||||||
explicit frmFramelessWidget(QWidget *parent = 0);
|
explicit frmFramelessWidget(QWidget *parent = 0);
|
||||||
~frmFramelessWidget();
|
~frmFramelessWidget();
|
||||||
|
|
||||||
protected:
|
|
||||||
void closeEvent(QCloseEvent *);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::frmFramelessWidget *ui;
|
Ui::frmFramelessWidget *ui;
|
||||||
QWidget *widget;
|
QWidget *widget;
|
||||||
FramelessWidget2 *frameless;
|
FramelessWidget2 *frameless;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void initForm();
|
||||||
void initWidget(QWidget *w);
|
void initWidget(QWidget *w);
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
void stateChanged1(int arg1);
|
void stateChanged1(int arg1);
|
||||||
void stateChanged2(int arg1);
|
void stateChanged2(int arg1);
|
||||||
|
void buttonClicked();
|
||||||
void on_btnDialog_clicked();
|
|
||||||
void on_btnWidget_clicked();
|
|
||||||
void on_btnMainWindow_clicked();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FRMFRAMELESSWIDGET_H
|
#endif // FRMFRAMELESSWIDGET_H
|
||||||
|
|||||||
@@ -203,8 +203,8 @@ void LunarCalendarWidget::initWidget()
|
|||||||
connect(btnPrevMonth, SIGNAL(clicked(bool)), this, SLOT(showPreviousMonth()));
|
connect(btnPrevMonth, SIGNAL(clicked(bool)), this, SLOT(showPreviousMonth()));
|
||||||
connect(btnNextMonth, SIGNAL(clicked(bool)), this, SLOT(showNextMonth()));
|
connect(btnNextMonth, SIGNAL(clicked(bool)), this, SLOT(showNextMonth()));
|
||||||
connect(btnToday, SIGNAL(clicked(bool)), this, SLOT(showToday()));
|
connect(btnToday, SIGNAL(clicked(bool)), this, SLOT(showToday()));
|
||||||
connect(cboxYear, SIGNAL(currentIndexChanged(QString)), this, SLOT(yearChanged(QString)));
|
connect(cboxYear, SIGNAL(currentIndexChanged(int)), this, SLOT(yearChanged(int)));
|
||||||
connect(cboxMonth, SIGNAL(currentIndexChanged(QString)), this, SLOT(monthChanged(QString)));
|
connect(cboxMonth, SIGNAL(currentIndexChanged(int)), this, SLOT(monthChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LunarCalendarWidget::initStyle()
|
void LunarCalendarWidget::initStyle()
|
||||||
@@ -351,26 +351,28 @@ void LunarCalendarWidget::initDate()
|
|||||||
dayChanged(this->date);
|
dayChanged(this->date);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LunarCalendarWidget::yearChanged(const QString &arg1)
|
void LunarCalendarWidget::yearChanged(int)
|
||||||
{
|
{
|
||||||
//如果是单击按钮切换的日期变动则不需要触发
|
//如果是单击按钮切换的日期变动则不需要触发
|
||||||
if (btnClick) {
|
if (btnClick) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString arg1 = cboxYear->currentText();
|
||||||
int year = arg1.mid(0, arg1.length() - 1).toInt();
|
int year = arg1.mid(0, arg1.length() - 1).toInt();
|
||||||
int month = date.month();
|
int month = date.month();
|
||||||
int day = date.day();
|
int day = date.day();
|
||||||
dateChanged(year, month, day);
|
dateChanged(year, month, day);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LunarCalendarWidget::monthChanged(const QString &arg1)
|
void LunarCalendarWidget::monthChanged(int)
|
||||||
{
|
{
|
||||||
//如果是单击按钮切换的日期变动则不需要触发
|
//如果是单击按钮切换的日期变动则不需要触发
|
||||||
if (btnClick) {
|
if (btnClick) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString arg1 = cboxMonth->currentText();
|
||||||
int year = date.year();
|
int year = date.year();
|
||||||
int month = arg1.mid(0, arg1.length() - 1).toInt();
|
int month = arg1.mid(0, arg1.length() - 1).toInt();
|
||||||
int day = date.day();
|
int day = date.day();
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ private slots:
|
|||||||
void initWidget();
|
void initWidget();
|
||||||
void initStyle();
|
void initStyle();
|
||||||
void initDate();
|
void initDate();
|
||||||
void yearChanged(const QString &arg1);
|
void yearChanged(int);
|
||||||
void monthChanged(const QString &arg1);
|
void monthChanged(int);
|
||||||
void clicked(const QDate &date, const LunarCalendarItem::DayType &dayType);
|
void clicked(const QDate &date, const LunarCalendarItem::DayType &dayType);
|
||||||
void dayChanged(const QDate &date);
|
void dayChanged(const QDate &date);
|
||||||
void dateChanged(int year, int month, int day);
|
void dateChanged(int year, int month, int day);
|
||||||
|
|||||||
Reference in New Issue
Block a user