改进代码

This commit is contained in:
feiyangqingyun
2021-09-20 12:46:24 +08:00
parent e1065dd361
commit c1137a20ee
35 changed files with 1220 additions and 693 deletions

View File

@@ -2,11 +2,12 @@
#include "frmsaveruntime.h"
#include "ui_frmsaveruntime.h"
#include "qfile.h"
#include "saveruntime.h"
frmSaveRunTime::frmSaveRunTime(QWidget *parent) : QWidget(parent), ui(new Ui::frmSaveRunTime)
{
ui->setupUi(this);
ui->setupUi(this);
}
frmSaveRunTime::~frmSaveRunTime()
@@ -21,4 +22,27 @@ void frmSaveRunTime::on_checkBox_stateChanged(int arg1)
} else {
SaveRunTime::Instance()->start();
}
on_btnOpen_clicked();
}
void frmSaveRunTime::on_btnAppend_clicked()
{
SaveRunTime::Instance()->initLog();
SaveRunTime::Instance()->appendLog();
on_btnOpen_clicked();
}
void frmSaveRunTime::on_btnUpdate_clicked()
{
SaveRunTime::Instance()->saveLog();
on_btnOpen_clicked();
}
void frmSaveRunTime::on_btnOpen_clicked()
{
QString fileName = QString("%1/examples_runtime_%2.txt").arg(qApp->applicationDirPath()).arg(QDate::currentDate().year());
QFile file(fileName);
if (file.open(QFile::ReadOnly | QFile::Text)) {
ui->txtMain->setText(file.readAll());
}
}

View File

@@ -20,6 +20,9 @@ private:
private slots:
void on_checkBox_stateChanged(int arg1);
void on_btnAppend_clicked();
void on_btnUpdate_clicked();
void on_btnOpen_clicked();
};
#endif // FRMSAVERUNTIME_H

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
@@ -15,24 +15,70 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<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>
<widget class="QTextEdit" name="txtMain"/>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>启动服务</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>启动服务</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnAppend">
<property name="minimumSize">
<size>
<width>130</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>插入一条记录</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnUpdate">
<property name="minimumSize">
<size>
<width>130</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>更新一条记录</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnOpen">
<property name="minimumSize">
<size>
<width>130</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>打开记录文件</string>
</property>
</widget>
</item>
<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>
</layout>
</item>
</layout>
</widget>