Compare commits
No commits in common. "3aad444cdfea6567c6c2dbbcf0f2a3949a560158" and "0a0afb1a0d231fec7a54f22d6e1e340719faba0d" have entirely different histories.
3aad444cdf
...
0a0afb1a0d
|
@ -1,23 +1,8 @@
|
|||
#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()
|
||||
|
|
|
@ -2,15 +2,11 @@
|
|||
#define WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
class Widget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QPushButton *button;
|
||||
|
||||
public:
|
||||
Widget(QWidget *parent = nullptr);
|
||||
~Widget();
|
||||
|
|
|
@ -1,38 +1,11 @@
|
|||
#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();
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
QT += core gui charts serialport
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
|
@ -16,43 +16,16 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||
#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
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
classifierwidget.h \
|
||||
dynamichistogramwidget.h \
|
||||
homewidget.h \
|
||||
mainwindow.h \
|
||||
operationallogwidget.h \
|
||||
passwordsettingwidget.h \
|
||||
registerwidget.h \
|
||||
serialportdebuggingwindow.h \
|
||||
settingswidget.h
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
classifierwidget.ui \
|
||||
dynamichistogramwidget.ui \
|
||||
homewidget.ui \
|
||||
mainwindow.ui \
|
||||
operationallogwidget.ui \
|
||||
passwordsettingwidget.ui \
|
||||
registerwidget.ui \
|
||||
serialportdebuggingwindow.ui \
|
||||
settingswidget.ui
|
||||
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
|
||||
|
||||
RESOURCES += \
|
||||
res.qrc
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
#include "classifierwidget.h"
|
||||
#include "ui_classifierwidget.h"
|
||||
|
||||
ClassifierWidget::ClassifierWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ClassifierWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
ClassifierWidget::~ClassifierWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
#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
|
|
@ -1,99 +0,0 @@
|
|||
<?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 "微软雅黑";</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 "微软雅黑";</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 "微软雅黑";</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 "微软雅黑";</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 "微软雅黑";</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>查询</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,88 +0,0 @@
|
|||
#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;
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
#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
|
|
@ -1,186 +0,0 @@
|
|||
<?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 "微软雅黑";</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>
|
|
@ -1,111 +0,0 @@
|
|||
#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);
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
#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
|
|
@ -1,307 +0,0 @@
|
|||
<?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 "微软雅黑";</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 "微软雅黑";</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>
|
Before Width: | Height: | Size: 90 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 928 B |
Before Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 226 B |
Before Width: | Height: | Size: 822 B |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 425 B |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 828 B |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 1.8 MiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 989 B |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 893 B |
Before Width: | Height: | Size: 751 B |
Before Width: | Height: | Size: 956 B |
Before Width: | Height: | Size: 858 B |
Before Width: | Height: | Size: 298 B |
Before Width: | Height: | Size: 298 B |