Compare commits

..

10 Commits

Author SHA1 Message Date
flykhan 3aad444cdf 其他 2023-08-13 11:47:17 +08:00
flykhan 4f2d4f5d87 串口项目 2023-08-13 11:47:00 +08:00
flykhan 0a0afb1a0d day4: 基于day3,添加Timer案例 2023-08-10 12:05:02 +08:00
flykhan cd4484ebe5 day3: 案例综合(常用控件、消息) 2023-08-09 18:22:00 +08:00
flykhan c92c63bb96 day2: homework 第二到六题 2023-08-08 22:37:07 +08:00
flykhan c35c647b8b day2: homework 第一题 2023-08-08 22:36:21 +08:00
flykhan 01c4a6e3ad day1: homework 初始版本 2023-08-08 17:47:59 +08:00
flykhan 9522ecd007 自己练的MenuBar 2023-08-08 17:43:15 +08:00
flykhan 1464145959 Qt dialog 2023-08-08 17:42:39 +08:00
flykhan f6d37a40a2 qt第二天: MainWindow 2023-08-08 14:39:49 +08:00
436 changed files with 7483 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
+28
View File
@@ -0,0 +1,28 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
widget.cpp
HEADERS += \
widget.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
+11
View File
@@ -0,0 +1,11 @@
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
+26
View File
@@ -0,0 +1,26 @@
#include "widget.h"
#include <QFileDialog>
#include <QString>
#include <QDebug>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
this->resize(600,400);
button = new QPushButton("选择文件",this);
button->resize(100,100);
button->move(250,100);
connect(button,&QPushButton::clicked,[](){
// QString str = QFileDialog::getOpenFileName();
// qDebug()<<str;
QStringList str = QFileDialog::getOpenFileNames();
qDebug()<<str;
});
}
Widget::~Widget()
{
}
+18
View File
@@ -0,0 +1,18 @@
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QPushButton>
class Widget : public QWidget
{
Q_OBJECT
private:
QPushButton *button;
public:
Widget(QWidget *parent = nullptr);
~Widget();
};
#endif // WIDGET_H
+73
View File
@@ -0,0 +1,73 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
+31
View File
@@ -0,0 +1,31 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
+38
View File
@@ -0,0 +1,38 @@
#include "mainwindow.h"
#include <QApplication>
#include <QLabel>
#include <QMouseEvent>
class EventLabel : public QLabel
{
protected:
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
};
void EventLabel::mouseMoveEvent(QMouseEvent *event){
this->setText(QString("<center><h1>Move: (%1, %2)</h1></center>").arg(QString::number(event->x()),QString::number(event->y)));
}
void EventLabel::mousePressEvent(QMouseEvent *event){
this->setText(QString("<center><h1>Press: (%1, %2)</h1></center>").arg(QString::number(event->x()),QString::number(event->y)));
}
void EventLabel::mouseReleaseEvent(QMouseEvent *event){
QString msg;
msg.sprintf("<center><h1>Release: (%d, %d)</h1></center>", event->x(), event->y());
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
EventLabel *label = new EventLabel;
label->setWindowTitle("MouseEvent Demo");
label->resize(300,200);
label->show();
return a.exec();
}
+15
View File
@@ -0,0 +1,15 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
+22
View File
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar"/>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
+31
View File
@@ -0,0 +1,31 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
res.qrc
+11
View File
@@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
+137
View File
@@ -0,0 +1,137 @@
#include "mainwindow.h"
#include <QPushButton>
#include <QLabel>
/*-------------------------*/
#include <QMenuBar> // 菜单栏
#include <QMenu> // 菜单
#include <QAction> // 菜单项
#include <QDebug>
/*-------------------------*/
#include <QToolBar> // 工具栏
/*-------------------------*/
#include <QStatusBar> // 状态栏
/*-------------------------*/
#include <QDockWidget> // 铆接部件
/*-------------------------*/
#include <QTextEdit> // 核心部件: 编辑器
/*-------------------------*/
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
// 第一部分: 5.1 菜单栏
//**********窗口属性设置*****************
this->setWindowTitle("主窗口");
this->setFixedSize(800, 600);
//***********创建菜单栏******************
//创建菜单栏
//注意:如果只有菜单栏,则在窗口处没有现象
QMenuBar *menu_bar = new QMenuBar(this);
this->setMenuBar(menu_bar);
// 创建菜单
QMenu *menu1 = new QMenu("文件",this);
menu_bar->addMenu(menu1);
QMenu *menu2 = new QMenu("编辑",this);
menu_bar->addMenu(menu2);
QMenu *menu3 = new QMenu("构建",this);
menu_bar->addMenu(menu3);
// 创建菜单项
QAction *act1 = new QAction("新建文件或项目",this);
menu1->addAction(act1);
QAction *act2 = new QAction("打开文件或项目",this);
menu1->addAction(act2);
// 添加分隔线
menu1->addSeparator();
QAction *act3 = new QAction("保存", this);
menu1->addAction(act3);
QAction *act4 = new QAction("另存为", this);
menu1->addAction(act4);
QAction *act5 = new QAction("复制", this);
act5->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_C)); // 绑定快捷键
menu2->addAction(act5);
QAction *act6 = new QAction("粘贴", this);
act6->setShortcut(QKeySequence(tr("Ctrl+V")));
menu2->addAction(act6);
QAction *act7 = new QAction("剪切", this);
menu2->addAction(act7);
// 当单机菜单项时,做出相应的处理
connect(act5,&QAction::triggered,[=]()->void{
qDebug()<<"复制正在执行";
});
connect(act6,&QAction::triggered,[=]()->void{
qDebug()<<"粘贴正在执行";
});
// 第二部分: 5.2 工具栏
//创建工具栏
//注意:工具栏可以添加多个
QToolBar *toolbar = new QToolBar(this);
//将工具栏添加到窗口
// this->addToolBar(toolbar);//默认在最上面显示
this->addToolBar(Qt::LeftToolBarArea, toolbar); //设置默认在左边显示
//工具栏添加菜单项和分割线
QAction *act_tool1 = new QAction("欢迎", this);
QAction *act_tool2 = new QAction("编辑", this);
toolbar->addAction(act_tool1);
toolbar->addSeparator();
toolbar->addAction(act_tool2);
//设置工具栏的浮动状态,true:可以悬浮在窗口 false:不可以
toolbar->setFloatable(true);
//设置运行工具栏的位置,设置为左边或者右边
toolbar->setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea | Qt::TopToolBarArea | Qt::BottomToolBarArea);
// 第三部分: 5.3 状态栏
//创建状态栏
//状态栏只能有一个
QStatusBar *statusbar = new QStatusBar(this);
//添加状态栏
this->setStatusBar(statusbar);
//给状态栏中添加文字信息或者按钮=
QLabel *label1 = new QLabel("左边信息", this);
statusbar->addWidget(label1);
QLabel *label2 = new QLabel("右边信息", this);
statusbar->addPermanentWidget(label2);
QPushButton *button = new QPushButton("设置", this);
statusbar->addWidget(button);
// 第四部分: 5.4 铆接部件 QDockWidget,也称浮动窗口,可以有多个。
//创建铆接部件
QDockWidget *dockwidget = new QDockWidget("这是一个铆接部件", this);
this->addDockWidget(Qt::TopDockWidgetArea, dockwidget);
// 第五部分: 5.5 核心部件(中心部件)
// 除了以上几个部件,中心显示的部件都可以作为核心部件,例如一个记事本文件,可以利用QTextEdit 做核心部件
QTextEdit *edit = new QTextEdit("文本编辑器", this);
this->setCentralWidget(edit);
}
MainWindow::~MainWindow()
{
}
+14
View File
@@ -0,0 +1,14 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
};
#endif // MAINWINDOW_H
+3
View File
@@ -0,0 +1,3 @@
<RCC>
<qresource prefix="/images"/>
</RCC>
+73
View File
@@ -0,0 +1,73 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
*~
*.autosave
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe
+58
View File
@@ -0,0 +1,58 @@
QT += core gui charts serialport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
classifierwidget.cpp \
dynamichistogramwidget.cpp \
homewidget.cpp \
main.cpp \
mainwindow.cpp \
operationallogwidget.cpp \
passwordsettingwidget.cpp \
registerwidget.cpp \
serialportdebuggingwindow.cpp \
settingswidget.cpp
HEADERS += \
classifierwidget.h \
dynamichistogramwidget.h \
homewidget.h \
mainwindow.h \
operationallogwidget.h \
passwordsettingwidget.h \
registerwidget.h \
serialportdebuggingwindow.h \
settingswidget.h
FORMS += \
classifierwidget.ui \
dynamichistogramwidget.ui \
homewidget.ui \
mainwindow.ui \
operationallogwidget.ui \
passwordsettingwidget.ui \
registerwidget.ui \
serialportdebuggingwindow.ui \
settingswidget.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
res.qrc
+14
View File
@@ -0,0 +1,14 @@
#include "classifierwidget.h"
#include "ui_classifierwidget.h"
ClassifierWidget::ClassifierWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::ClassifierWidget)
{
ui->setupUi(this);
}
ClassifierWidget::~ClassifierWidget()
{
delete ui;
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef CLASSIFIERWIDGET_H
#define CLASSIFIERWIDGET_H
#include <QWidget>
namespace Ui {
class ClassifierWidget;
}
class ClassifierWidget : public QWidget
{
Q_OBJECT
public:
explicit ClassifierWidget(QWidget *parent = nullptr);
~ClassifierWidget();
private:
Ui::ClassifierWidget *ui;
};
#endif // CLASSIFIERWIDGET_H
+99
View File
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ClassifierWidget</class>
<widget class="QWidget" name="ClassifierWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1021</width>
<height>691</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>120</x>
<y>170</y>
<width>131</width>
<height>61</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font: 75 14pt &quot;微软雅黑&quot;;</string>
</property>
<property name="text">
<string>分类器名称</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>280</x>
<y>180</y>
<width>401</width>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font: 75 14pt &quot;微软雅黑&quot;;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>800</x>
<y>160</y>
<width>100</width>
<height>70</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font: 75 14pt &quot;微软雅黑&quot;;</string>
</property>
<property name="text">
<string>增加</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>800</x>
<y>310</y>
<width>100</width>
<height>70</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font: 75 14pt &quot;微软雅黑&quot;;</string>
</property>
<property name="text">
<string>删除</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>800</x>
<y>460</y>
<width>100</width>
<height>70</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font: 75 14pt &quot;微软雅黑&quot;;</string>
</property>
<property name="text">
<string>查询</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
+88
View File
@@ -0,0 +1,88 @@
#include "dynamichistogramwidget.h"
#include "ui_dynamichistogramwidget.h"
QVector<int>data0;
QVector<int>data1;
QVector<int>data2;
QVector<int>data3;
using namespace QtCharts;
DynamicHistogramWidget::DynamicHistogramWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::DynamicHistogramWidget)
{
ui->setupUi(this);
for (int i = 0; i < 7; ++i) {
data0.push_front(0);
data1.push_front(0);
data2.push_front(0);
data3.push_front(0);
}
connect(ui->createBtn,&QPushButton::clicked,[=](){
data0.push_front(ui->line1->text().toInt());
data1.push_front(ui->line2->text().toInt());
data2.push_front(ui->line3->text().toInt());
data3.push_front(ui->line4->text().toInt());
QBarSet *set0 = new QBarSet("日光(min)");
QBarSet *set1 = new QBarSet("UV(min)");
QBarSet *set2 = new QBarSet("日光(month)");
QBarSet *set3 = new QBarSet("UV(month)");
QVector<int>::iterator it1 = data0.begin();
QVector<int>::iterator it2 = data1.begin();
QVector<int>::iterator it3 = data2.begin();
qDebug()<<it1<<"|"<<it2<<"|"<<it3;
//if(i)
for(QVector<int>::iterator it4 = data3.begin();it4<data3.begin()+5;it4++)
{
*set0 << *it1<< *(it1+1) << *(it1+2) << *(it1+3) << *(it1+4) << *(it1+5);
*set1 << *it2<< *(it2+1) << *(it2+2) << *(it2+3) << *(it2+4) << *(it2+5);
*set2 << *it3<< *(it3+1) << *(it3+2) << *(it3+3) << *(it3+4) << *(it3+5);
*set3 << *it4<< *(it4+1) << *(it4+2) << *(it4+3) << *(it4+4) << *(it4+5);
it1++;
it2++;
it3++;
}
// *set0 << 5 << 2 << 3 << 4 << 5 << 6;
// *set1 << 7 << 0 << 0 << 4 << 0 << 7;
// *set2 << 9 << 5 << 8 << 19<< 8 << 5;
// *set3 << 5 << 6 << 7 << 3 << 4 << 5;
QBarSeries *series = new QBarSeries();
series->append(set0);
series->append(set1);
series->append(set2);
series->append(set3);
QChart *c = new QChart();
c->setTitle("光照UV强度");
c->addSeries(series);
ui->graphicsView->setChart(c);
c->legend()->setVisible(true);
c->setAnimationOptions(QChart::SeriesAnimations);
ui->graphicsView->setRenderHint(QPainter::Antialiasing);
c->createDefaultAxes();//创建默认的左侧的坐标轴(根据 QBarSet 设置的值)
QValueAxis *axisX = new QValueAxis();//轴变量、数据系列变量,都不能声明为局部临时变量
QValueAxis *axisY = new QValueAxis();//创建X/Y轴
axisX->setRange(0, 7);
axisY->setRange(0, 10);//设置X/Y显示的区间
// c->setAxisX(axisX);
// c->setAxisY(axisY);//设置chart的坐标轴
// series->attachAxis(axisX);
c->addAxis(axisX,Qt::AlignBottom);
// c->addAxis(axisY,Qt::AlignLeft);
series->attachAxis(axisX);
// series->attachAxis(axisY);
c->legend()->setVisible(true); //设置图例为显示状态
c->legend()->setAlignment(Qt::AlignBottom);//设置图例的显示位置在底部
});
}
DynamicHistogramWidget::~DynamicHistogramWidget()
{
delete ui;
}
+54
View File
@@ -0,0 +1,54 @@
#ifndef DYNAMICHISTOGRAMWIDGET_H
#define DYNAMICHISTOGRAMWIDGET_H
#include <QWidget>
// 柱状图
#include <QtCharts>
#include <QBarSeries>
#include <QBarSet>
#include <QtCharts>
#include <QPushButton>
#include <QtCharts/QChartView>
#include <QtCharts/QPieSeries>
#include <QtCharts/QPieSlice>
#include <QtCharts/QAbstractBarSeries>
#include <QtCharts/QPercentBarSeries>
#include <QtCharts/QStackedBarSeries>
#include <QtCharts/QBarSeries>
#include <QtCharts/QBarSet>
#include <QtCharts/QLineSeries>
#include <QtCharts/QSplineSeries>
#include <QtCharts/QScatterSeries>
#include <QtCharts/QAreaSeries>
#include <QtCharts/QLegend>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QLabel>
#include <QtCharts/QBarCategoryAxis>
#include <QtWidgets/QApplication>
#include <QtCharts/QValueAxis>
#include <QVector>
#include <QDebug>
namespace Ui {
class DynamicHistogramWidget;
}
class DynamicHistogramWidget : public QWidget
{
Q_OBJECT
public:
explicit DynamicHistogramWidget(QWidget *parent = nullptr);
~DynamicHistogramWidget();
private:
Ui::DynamicHistogramWidget *ui;
};
#endif // DYNAMICHISTOGRAMWIDGET_H
+186
View File
@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DynamicHistogramWidget</class>
<widget class="QWidget" name="DynamicHistogramWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1182</width>
<height>709</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>110</y>
<width>191</width>
<height>444</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>日光次数(分钟)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="line1"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>紫外次数(分钟)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="line2"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>日光次数(小时)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="line3"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="widget_4" native="true">
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>紫外次数(小时)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="line4"/>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="createBtn">
<property name="geometry">
<rect>
<x>50</x>
<y>570</y>
<width>121</width>
<height>51</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font: 20pt &quot;微软雅黑&quot;;</string>
</property>
<property name="text">
<string>生成</string>
</property>
</widget>
<widget class="QChartView" name="graphicsView">
<property name="geometry">
<rect>
<x>230</x>
<y>10</y>
<width>901</width>
<height>671</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>QChartView</class>
<extends>QGraphicsView</extends>
<header location="global">qchartview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
+111
View File
@@ -0,0 +1,111 @@
#include "homewidget.h"
#include "ui_homewidget.h"
HomeWidget::HomeWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::HomeWidget)
{
// 计时器
timer = new QTimer(this);
connect(timer,&QTimer::timeout,[&]{
QDateTime cur_datetime = QDateTime::currentDateTime();
QString cur_date = cur_datetime.toString("yyyy.MM.dd");
QString cur_time = cur_datetime.toString("hh:mm:ss");
ui->datetimeLabel->setText(cur_date+"\n"+cur_time);
});
timer->start(1000);
ui->setupUi(this);
change_port_label_show(); // 修改串口连接信息
this->setWindowTitle("不知名系统");
this->setWindowIcon(QIcon(":logo"));
// 启用所有按钮
ui->homeBtn->setEnabled(true);
ui->exitBtn->setEnabled(true);
ui->logsBtn->setEnabled(true);
ui->statusBtn->setEnabled(true);
ui->settingBtn->setEnabled(true);
}
HomeWidget::~HomeWidget()
{
delete ui;
delete timer;
}
void HomeWidget::on_exitBtn_clicked()
{
// emit this->exit_to_shell_window();
// this->close();
QApplication::quit();
}
void HomeWidget::on_homeBtn_clicked()
{
ui->homeStackWidget->setCurrentIndex(0);
ui->homeBtn->setEnabled(false); // 按钮按下后禁用当前,并启用其他按钮,防止多次点击
ui->exitBtn->setEnabled(true);
ui->logsBtn->setEnabled(true);
ui->statusBtn->setEnabled(true);
ui->settingBtn->setEnabled(true);
}
void HomeWidget::on_settingBtn_clicked()
{
ui->homeStackWidget->setCurrentIndex(1);
ui->homeBtn->setEnabled(true);
ui->exitBtn->setEnabled(true);
ui->logsBtn->setEnabled(true);
ui->statusBtn->setEnabled(true);
ui->settingBtn->setEnabled(false);
}
void HomeWidget::change_port_label_show()
{
qDebug() <<"可用串口信息"<<endl;
QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
for(int i = 0; i<ports.size();i++){
QSerialPortInfo info = ports.at(i);
qDebug() << info.portName();
}
if(ports.size()!=0){ // 当串口不为空时,至少存在一个串口
QSerialPortInfo portid = ports.at(0); // 获取第一个串口
// emit send_connected_port_id(portid.portName()); // 将串口名广播出去
// 将获取的串口信息显示出来
ui->port_con_msg->setStyleSheet("background-color: rgb(0, 170, 255)");
QFont font("微软雅黑",18);
ui->port_con_msg->setFont(font); // 设置字体
ui->port_con_msg->setAlignment(Qt::AlignCenter); // 居中显示
ui->port_con_msg->setText("串口: "+portid.portName()+" 已连接");
}
// qDebug() <<"可用波特率信息"<<endl;
// QList<qint32> rates = QSerialPortInfo::standardBaudRates();
// for(int i=0;i<rates.size();i++){
// qDebug()<<rates.at(i);
// }
}
void HomeWidget::on_statusBtn_clicked()
{
ui->homeBtn->setEnabled(true);
ui->exitBtn->setEnabled(true);
ui->logsBtn->setEnabled(true);
ui->statusBtn->setEnabled(false);
ui->settingBtn->setEnabled(true);
}
void HomeWidget::on_logsBtn_clicked()
{
ui->homeBtn->setEnabled(true);
ui->exitBtn->setEnabled(true);
ui->logsBtn->setEnabled(false);
ui->statusBtn->setEnabled(true);
ui->settingBtn->setEnabled(true);
}
+54
View File
@@ -0,0 +1,54 @@
#ifndef HOMEWIDGET_H
#define HOMEWIDGET_H
#include <QWidget>
// 计时器
#include <QTimer> // timer
#include <QDateTime>
// 串口信息
#include <QList>
#include <QtSerialPort/QSerialPortInfo>
#include <QDebug>
#include "serialportdebuggingwindow.h"
namespace Ui {
class HomeWidget;
}
class HomeWidget : public QWidget
{
Q_OBJECT
private:
QTimer *timer;
private:
void change_port_label_show();
public:
explicit HomeWidget(QWidget *parent = nullptr);
~HomeWidget();
private slots:
void on_exitBtn_clicked();
void on_homeBtn_clicked();
void on_settingBtn_clicked();
void on_statusBtn_clicked();
void on_logsBtn_clicked();
private:
Ui::HomeWidget *ui;
signals:
void exit_to_shell_window();
};
#endif // HOMEWIDGET_H
+307
View File
@@ -0,0 +1,307 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>HomeWidget</class>
<widget class="QWidget" name="HomeWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1200</width>
<height>900</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0" colspan="3">
<widget class="QStackedWidget" name="homeStackWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="DynamicHistogramWidget" name="home_page"/>
<widget class="SettingsWidget" name="settings_page"/>
</widget>
</item>
<item row="0" column="2">
<widget class="QWidget" name="widget_4" native="true">
<widget class="QLabel" name="datetimeLabel_2">
<property name="geometry">
<rect>
<x>30</x>
<y>30</y>
<width>72</width>
<height>15</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QWidget" name="widget_2" native="true">
<widget class="QLabel" name="datetimeLabel">
<property name="geometry">
<rect>
<x>11</x>
<y>4</y>
<width>291</width>
<height>51</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font: 12pt &quot;微软雅黑&quot;;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</item>
<item row="0" column="1">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="port_con_msg">
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 0, 0);
font: 18pt &quot;微软雅黑&quot;;</string>
</property>
<property name="text">
<string>PLC读取失败: 串口未连接!</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="homeBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>homeBtn</string>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/home</normaloff>:/home</iconset>
</property>
<property name="iconSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="settingBtn">
<property name="text">
<string>settingBtn</string>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/set</normaloff>:/set</iconset>
</property>
<property name="iconSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="statusBtn">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/picture</normaloff>:/picture</iconset>
</property>
<property name="iconSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="logsBtn">
<property name="text">
<string>logsBtn</string>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/history</normaloff>:/history</iconset>
</property>
<property name="iconSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="exitBtn">
<property name="text">
<string>exitBtn</string>
</property>
<property name="icon">
<iconset resource="res.qrc">
<normaloff>:/exit2</normaloff>:/exit2</iconset>
</property>
<property name="iconSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>DynamicHistogramWidget</class>
<extends>QWidget</extends>
<header>dynamichistogramwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>SettingsWidget</class>
<extends>QWidget</extends>
<header>settingswidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="res.qrc"/>
</resources>
<connections/>
</ui>
Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Some files were not shown because too many files have changed in this diff Show More