|
|
@ -3,8 +3,10 @@ |
|
|
|
#include <QDateTime>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QtConcurrent>
|
|
|
|
#include <QtCore/QVariant>
|
|
|
|
#include <QtSerialPort/QSerialPort>
|
|
|
|
#include <QtSerialPort/QSerialPortInfo>
|
|
|
|
#include <QtWidgets/QLineEdit>
|
|
|
|
|
|
|
|
#include "./ui_mainwindow.h"
|
|
|
|
#include "electrocardiograph_tester.hpp"
|
|
|
@ -24,6 +26,8 @@ static QTDataChannel G_QTDataChannel; |
|
|
|
static QTDataChannel G_WaveDataChannel; |
|
|
|
static device_type_t m_devicetype; |
|
|
|
|
|
|
|
QT_REQUIRE_CONFIG(groupbox); |
|
|
|
|
|
|
|
#define TAG "MainWindow"
|
|
|
|
|
|
|
|
static const char *fmt(const char *fmt, ...) { |
|
|
@ -40,6 +44,10 @@ void MainWindow::doinui_slot(QFunction func) { |
|
|
|
if (func.get()) func.get()(); |
|
|
|
} |
|
|
|
|
|
|
|
/***********************************************************************************************************************
|
|
|
|
* PreviewShow * |
|
|
|
***********************************************************************************************************************/ |
|
|
|
|
|
|
|
void MainWindow::instructionPreviewShow(const char *fmt, ...) { |
|
|
|
va_list args; |
|
|
|
va_start(args, fmt); |
|
|
@ -148,43 +156,14 @@ void MainWindow::displayWave(int16_t wave1, int16_t wave2, int16_t wave3) { |
|
|
|
G_WaveDataChannel.send((uint8_t *)&wave, sizeof(wave)); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::displayInfo(bool suc, QString info) {} |
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { |
|
|
|
/*******************************************************************************
|
|
|
|
* QT初始化 * |
|
|
|
*******************************************************************************/ |
|
|
|
ui->setupUi(this); |
|
|
|
m_mainWindow = this; |
|
|
|
qRegisterMetaType<int32_t>("int32_t"); |
|
|
|
qRegisterMetaType<uint32_t>("uint32_t"); |
|
|
|
qRegisterMetaType<float>("float"); |
|
|
|
qRegisterMetaType<function<void()>>("function<void()>"); |
|
|
|
qRegisterMetaType<QFunction>("QFunction"); |
|
|
|
connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); |
|
|
|
// qInstallMessageHandler(log_output);
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 页面逻辑初始化 * |
|
|
|
*******************************************************************************/ |
|
|
|
constructUI(); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 业务逻辑构造 * |
|
|
|
*******************************************************************************/ |
|
|
|
G_QTDataChannel.init(); |
|
|
|
G_WaveDataChannel.init(); |
|
|
|
ElectrocardiographTester::ins()->initialize(&G_QTDataChannel); |
|
|
|
} |
|
|
|
MainWindow::~MainWindow() { delete ui; } |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
/***********************************************************************************************************************
|
|
|
|
* UI相关构造 * |
|
|
|
*******************************************************************************/ |
|
|
|
void MainWindow::constructUI() { |
|
|
|
/*******************************************************************************
|
|
|
|
* 指令串口UI * |
|
|
|
*******************************************************************************/ |
|
|
|
***********************************************************************************************************************/ |
|
|
|
|
|
|
|
void MainWindow::constructBaseUI() { |
|
|
|
/**
|
|
|
|
* @brief 指令串口UI |
|
|
|
*/ |
|
|
|
{ |
|
|
|
const auto infos = QSerialPortInfo::availablePorts(); |
|
|
|
for (const QSerialPortInfo &info : infos) { |
|
|
@ -238,9 +217,9 @@ void MainWindow::constructUI() { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 波形串口UI * |
|
|
|
*******************************************************************************/ |
|
|
|
/**
|
|
|
|
* @brief 波形串口UI |
|
|
|
*/ |
|
|
|
{ |
|
|
|
const auto infos = QSerialPortInfo::availablePorts(); |
|
|
|
for (const QSerialPortInfo &info : infos) { |
|
|
@ -256,6 +235,7 @@ void MainWindow::constructUI() { |
|
|
|
ui->waveSerialBaudrateCB->addItem("115200"); |
|
|
|
ui->waveSerialBaudrateCB->addItem("460800"); |
|
|
|
ui->waveSerialBaudrateCB->addItem("500000"); |
|
|
|
// ui->waveSerialBaudrateCB->addItems
|
|
|
|
ui->waveSerialBaudrateCB->setCurrentIndex(6); |
|
|
|
|
|
|
|
connect(ui->waveSerialPortRefreshKey, &QPushButton::clicked, this, [this](bool check) { |
|
|
@ -293,267 +273,114 @@ void MainWindow::constructUI() { |
|
|
|
ui->waveSerialPortRefreshKey->setEnabled(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 事件填充
|
|
|
|
ElectrocardiographTester::ins()->regReportCB([this](bool checkok, ify_hrs_packet_t *report_packet, size_t len) { |
|
|
|
int reportType = report_packet->cmd; |
|
|
|
switch (reportType) { |
|
|
|
case ify_hrs_report_heartrate_data: { |
|
|
|
heartrate_report_packet_t *heartrate_report = (heartrate_report_packet_t *)report_packet; |
|
|
|
// reportPreviewShow("[preview data ] index %llu", heartrate_report->sample_data_index);
|
|
|
|
|
|
|
|
uint16_t header = 0xA55A; |
|
|
|
uint16_t tail = 0xB55B; |
|
|
|
G_WaveDataChannel.send((uint8_t *)&header, sizeof(header)); |
|
|
|
G_WaveDataChannel.send((uint8_t *)report_packet, len); |
|
|
|
G_WaveDataChannel.send((uint8_t *)&tail, sizeof(tail)); |
|
|
|
|
|
|
|
// if (m_devicetype == kone_lead_ecg) {
|
|
|
|
reportPreviewShow("[preview data ] checksum_ok:%d index %llu", checkok, heartrate_report->sample_data_index); |
|
|
|
// } else if (m_devicetype == kthree_lead_ecg) {
|
|
|
|
// displayWave(heartrate_report->data[0], heartrate_report->data[1], heartrate_report->data[2]);
|
|
|
|
// }
|
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
case ify_hrs_report_battery_level: { |
|
|
|
reportPreviewShow("[battery_level ]"); |
|
|
|
break; |
|
|
|
} |
|
|
|
case ify_hrs_report_low_battey_level: { |
|
|
|
reportPreviewShow("[low_battey ]"); |
|
|
|
break; |
|
|
|
} |
|
|
|
case ify_hrs_report_sample_finish_end: { |
|
|
|
reportPreviewShow("[sample_finish ]"); |
|
|
|
break; |
|
|
|
} |
|
|
|
case ify_hrs_report_sensor_drop_detect: { |
|
|
|
sensor_drop_event_report_packet_t *sensor_drop_report = (sensor_drop_event_report_packet_t *)report_packet->data; |
|
|
|
reportPreviewShow("[sensor_drop ] %s %s", zhex2binary(sensor_drop_report->drop_state0).c_str(), zhex2binary(sensor_drop_report->drop_state1).c_str()); |
|
|
|
break; |
|
|
|
} |
|
|
|
case ify_hrs_report_record_upload_end: { |
|
|
|
uint32_t checksum = *(uint32_t *)report_packet->data; |
|
|
|
reportPreviewShow("[upload end ] checksum: 0x%08x", checksum); |
|
|
|
break; |
|
|
|
} |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
ElectrocardiographTester::ins()->regCh4CheckSumPacketReport([this](uint32_t rxcnt, uint32_t report_packet_checksum) { //
|
|
|
|
blockDataUploadPreviewShow("RXCNT %d CHECKSUM 0x%08x", rxcnt, report_packet_checksum); |
|
|
|
}); |
|
|
|
ElectrocardiographTester::ins()->regRawDataCB([this](raw_data_type_t type, uint8_t *hex, uint32_t hexlen) { |
|
|
|
if (type == kcmd_cmd) { |
|
|
|
rawDataPreviewShow("[CMD ] %s", zhex2str(hex, hexlen).c_str()); |
|
|
|
} else if (type == kcmd_receipt) { |
|
|
|
rawDataPreviewShow("[RECEIPT] %s", zhex2str(hex, hexlen).c_str()); |
|
|
|
} else if (type == kcmd_report) { |
|
|
|
rawDataPreviewShow("[REPORT ] %s", zhex2str(hex, hexlen).c_str()); |
|
|
|
} else if (type == kcmd_ch4_data) { |
|
|
|
// rawDataPreviewShow("[CH4 ] %s", zhex2str(hex, hexlen).c_str());
|
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::processException(zexception &e) { instructionPreviewShow("%s:%s", e.what(), hrs_ecode2str((ify_hrs_error_code_t)e.ecode())); } |
|
|
|
|
|
|
|
void MainWindow::on_readDeviceVersion_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
device_version_info_receipt_t version; |
|
|
|
ElectrocardiographTester::ins()->readDeviceVersion(&version); |
|
|
|
instructionPreviewShow("-------------- version ----------------"); |
|
|
|
instructionPreviewShow(" blestack_version: %d", version.blestack_version); |
|
|
|
instructionPreviewShow(" bootloader_version: %d", version.bootloader_version); |
|
|
|
instructionPreviewShow(" firmware_version: %d", version.firmware_version); |
|
|
|
instructionPreviewShow(" hardware_version: %d", version.hardware_version); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::on_readDeviceState_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
device_state_receipt_t state; |
|
|
|
ElectrocardiographTester::ins()->readDeviceState(&state); |
|
|
|
instructionPreviewShow("-------------- state ----------------"); |
|
|
|
instructionPreviewShow(" drop_state0: %s", zhex2binary(state.drop_state0).c_str()); |
|
|
|
instructionPreviewShow(" drop_state1: %s", zhex2binary(state.drop_state1).c_str()); |
|
|
|
|
|
|
|
instructionPreviewShow(" sampling_state: %d", state.device_state0.sampling_state); |
|
|
|
instructionPreviewShow(" report_state: %d", state.device_state0.report_state); |
|
|
|
instructionPreviewShow(" low_battery: %d", state.device_state0.low_battery); |
|
|
|
instructionPreviewShow(" full_storge: %d", state.device_state0.full_storge); |
|
|
|
instructionPreviewShow(" holder: %d", state.device_state0.holder); |
|
|
|
instructionPreviewShow(" powerlevel: %d", state.powerlevel); |
|
|
|
instructionPreviewShow(" storage_item_num: %d", state.storage_item_num); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::displayInfo(bool suc, QString info) {} |
|
|
|
|
|
|
|
void MainWindow::on_readTime_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
read_time_receipt_t time; |
|
|
|
ElectrocardiographTester::ins()->readTime(&time); |
|
|
|
instructionPreviewShow("-------------- time ----------------"); |
|
|
|
instructionPreviewShow(" %d/%d/%d %d:%d:%d", time.year + 2000, time.month, time.day, time.hour, time.minute, time.second); |
|
|
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { |
|
|
|
/**
|
|
|
|
* @brief QT初始化 |
|
|
|
*/ |
|
|
|
ui->setupUi(this); |
|
|
|
m_mainWindow = this; |
|
|
|
qRegisterMetaType<int32_t>("int32_t"); |
|
|
|
qRegisterMetaType<uint32_t>("uint32_t"); |
|
|
|
qRegisterMetaType<float>("float"); |
|
|
|
qRegisterMetaType<function<void()>>("function<void()>"); |
|
|
|
qRegisterMetaType<QFunction>("QFunction"); |
|
|
|
connect(this, SIGNAL(doinui_signal(QFunction)), this, SLOT(doinui_slot(QFunction))); |
|
|
|
|
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
} |
|
|
|
/**
|
|
|
|
* @brief 页面逻辑初始化 |
|
|
|
*/ |
|
|
|
constructBaseUI(); |
|
|
|
constructAppUI(); |
|
|
|
|
|
|
|
void MainWindow::on_syncTime_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
// 获取系统时间
|
|
|
|
QDateTime now = QDateTime::currentDateTime(); |
|
|
|
ElectrocardiographTester::ins()->syncTime(now.date().year() - 2000, now.date().month(), now.date().day(), now.time().hour(), now.time().minute(), now.time().second()); |
|
|
|
instructionPreviewShow("sync time success!"); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
/**
|
|
|
|
* @brief 业务逻辑构造 |
|
|
|
*/ |
|
|
|
G_QTDataChannel.init(); |
|
|
|
G_WaveDataChannel.init(); |
|
|
|
ElectrocardiographTester::ins()->initialize(&G_QTDataChannel); |
|
|
|
} |
|
|
|
MainWindow::~MainWindow() { delete ui; } |
|
|
|
|
|
|
|
std::string zhex2time(const uint8_t *hex, size_t len) { |
|
|
|
std::string str; |
|
|
|
if (len < 6) return str; |
|
|
|
str.append(fmt("%d/%d/%d %2d:%2d:%2d", hex[0] + 2000, hex[1], hex[2], hex[3], hex[4], hex[5])); |
|
|
|
return str; |
|
|
|
void MainWindow::processException(zexception &e) { //
|
|
|
|
instructionPreviewShow("%s:%s", e.what(), hrs_ecode2str((ify_hrs_error_code_t)e.ecode())); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::on_readAllRecords_clicked() { |
|
|
|
// 读取当前有多少条记录
|
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
device_state_receipt_t state; |
|
|
|
ElectrocardiographTester::ins()->readDeviceState(&state); |
|
|
|
instructionPreviewShow("index recordid frameNum dataSize sensorNum captRate captPrec compAlgo checksum"); |
|
|
|
for (int32_t i = 0; i < state.storage_item_num; i++) { |
|
|
|
read_record_info_receipt_t record; |
|
|
|
ElectrocardiographTester::ins()->readRecordsInfo(i, &record); |
|
|
|
instructionPreviewShow("%d %s %8d %8d %8d %8d %8d %8d 0x%08x", i, zhex2time(record.record_id, 6).c_str(), record.frameNum, record.dataSize, record.sensorNum, record.captureRate, record.capturePrecision, record.compressAlgorithm, record.checksum); |
|
|
|
void MainWindow::constructAppUI() { |
|
|
|
{ |
|
|
|
QWidget *tab = allocNewTab("测试TAB"); |
|
|
|
{ |
|
|
|
{ |
|
|
|
QGroupBox *box = allocNewBox(tab, "测试BOX", 4); |
|
|
|
allocNewButtonStyle1(box, "测试按钮1", {"123", "456"}, //
|
|
|
|
[](int argn, const char **args) { m_mainWindow->instructionPreviewShow("测试按钮1"); }); |
|
|
|
allocNewButtonStyle1(box, "测试按钮1", {"123"}, //
|
|
|
|
[](int argn, const char **args) { m_mainWindow->instructionPreviewShow("测试按钮1"); }); |
|
|
|
endAllocNewBox(box); |
|
|
|
} |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::on_startUploadRecord_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
int reportIndex = ui->startUploadRecord_p0->toPlainText().toInt(); |
|
|
|
try { |
|
|
|
read_record_info_receipt_t record; |
|
|
|
ElectrocardiographTester::ins()->readRecordsInfo(reportIndex, &record); |
|
|
|
ElectrocardiographTester::ins()->startUploadRecord(record.record_id); |
|
|
|
instructionPreviewShow("start upload record [%s] success", zhex2time(record.record_id, 6).c_str()); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
endAllocNewTab(tab); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::on_readSensorInfo_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
sensor_info_receipt_t sensor; |
|
|
|
ElectrocardiographTester::ins()->readSensorInfo(&sensor); |
|
|
|
instructionPreviewShow("-------------- sensor ----------------"); |
|
|
|
instructionPreviewShow(" sensor_num: %d", sensor.sensor_num); |
|
|
|
instructionPreviewShow(" sensor_precision: %d", sensor.sensor_precision); |
|
|
|
instructionPreviewShow(" sensor_sample_rate:%d", sensor.sensor_sample_rate); |
|
|
|
instructionPreviewShow(" sensor0_pos: %d", sensor.sensor0_pos); |
|
|
|
instructionPreviewShow(" sensor1_pos: %d", sensor.sensor1_pos); |
|
|
|
instructionPreviewShow(" sensor2_pos: %d", sensor.sensor2_pos); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
} |
|
|
|
QWidget *MainWindow::allocNewTab(QString zh_name) { |
|
|
|
QWidget *newtab = new QWidget(); |
|
|
|
QVBoxLayout *verticalLayout = new QVBoxLayout(newtab); // 设置布局
|
|
|
|
newtab->setLayout(verticalLayout); |
|
|
|
|
|
|
|
void MainWindow::on_readSN_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
string sn; |
|
|
|
ElectrocardiographTester::ins()->readSn(sn); |
|
|
|
instructionPreviewShow("-------------- sn ----------------"); |
|
|
|
instructionPreviewShow(" sn: %s", sn.c_str()); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
// 添加Tab
|
|
|
|
ui->buttonTabWidget->addTab(newtab, QString()); |
|
|
|
ui->buttonTabWidget->setTabText(ui->buttonTabWidget->indexOf(newtab), zh_name); |
|
|
|
return newtab; |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::on_stopUploadRecord_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
ElectrocardiographTester::ins()->stopUploadRecord(); |
|
|
|
instructionPreviewShow("stop upload record success"); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
void MainWindow::endAllocNewTab(QWidget *tab) { |
|
|
|
QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(tab->layout()); |
|
|
|
layout->addItem(new QSpacerItem(20, 445, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::on_delRecord_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
int reportIndex = ui->delRecord_p0->toPlainText().toInt(); |
|
|
|
try { |
|
|
|
read_record_info_receipt_t record; |
|
|
|
ElectrocardiographTester::ins()->readRecordsInfo(reportIndex, &record); |
|
|
|
ElectrocardiographTester::ins()->delRecord(record.record_id); |
|
|
|
instructionPreviewShow("delete record [%s] success", zhex2time(record.record_id, 6).c_str()); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
} |
|
|
|
QGroupBox *MainWindow::allocNewBox(QWidget *tab, QString zh_name, int column) { |
|
|
|
QVBoxLayout *tablayout = qobject_cast<QVBoxLayout *>(tab->layout()); |
|
|
|
|
|
|
|
void MainWindow::on_startCapture_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
ElectrocardiographTester::ins()->startCapture(); |
|
|
|
instructionPreviewShow("start capture success"); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
} |
|
|
|
QGroupBox *groupBox = new QGroupBox(tab); // 创建BOX
|
|
|
|
QGridLayout *gridLayout = new QGridLayout(groupBox); // 创建布局
|
|
|
|
groupBox->setLayout(gridLayout); // 设置布局
|
|
|
|
gridLayout->setColumnMinimumWidth(column, column); |
|
|
|
|
|
|
|
void MainWindow::on_stopCapture_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
ElectrocardiographTester::ins()->stopCapture(); |
|
|
|
instructionPreviewShow("stop capture success"); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
tablayout->addWidget(groupBox); |
|
|
|
return groupBox; |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::on_startRealtimeReport_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
ElectrocardiographTester::ins()->startRealtimeReport(); |
|
|
|
instructionPreviewShow("start realtime report success"); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
void MainWindow::endAllocNewBox(QGroupBox *box) { //
|
|
|
|
QGridLayout *layout = qobject_cast<QGridLayout *>(box->layout()); |
|
|
|
QSpacerItem *verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); |
|
|
|
layout->addItem(verticalSpacer, layout->rowCount(), 0, 1, 1); |
|
|
|
} |
|
|
|
|
|
|
|
void MainWindow::on_stopRealtimeReport_clicked() { |
|
|
|
instructionPreviewClear(); |
|
|
|
try { |
|
|
|
ElectrocardiographTester::ins()->stopRealtimeReport(); |
|
|
|
instructionPreviewShow("stop realtime report success"); |
|
|
|
} catch (zexception &exception) { |
|
|
|
processException(exception); |
|
|
|
} |
|
|
|
} |
|
|
|
void MainWindow::allocNewButtonStyle1(QWidget *box, QString zh_name, QStringList params, std::function<void(int argn, const char **args)> onButtonClick) { //
|
|
|
|
|
|
|
|
void MainWindow::on_clearPreview_clicked() { |
|
|
|
ui->reportPreview->document()->clear(); |
|
|
|
ui->uploadDataPreview->document()->clear(); |
|
|
|
ui->rawDataPreview->document()->clear(); |
|
|
|
ui->instructionPreview->document()->clear(); |
|
|
|
QGridLayout *layout = qobject_cast<QGridLayout *>(box->layout()); |
|
|
|
int rowcnt = layout->rowCount(); |
|
|
|
|
|
|
|
QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); |
|
|
|
sizePolicy.setHorizontalStretch(1); |
|
|
|
sizePolicy.setVerticalStretch(0); |
|
|
|
|
|
|
|
QPushButton *button = new QPushButton(box); |
|
|
|
button->setText(zh_name); |
|
|
|
button->setMinimumHeight(30); |
|
|
|
button->setSizePolicy(sizePolicy); |
|
|
|
layout->addWidget(button, rowcnt, 0, 1, 1); |
|
|
|
|
|
|
|
for (int i = 0; i < params.size(); i++) { |
|
|
|
QLineEdit *lineEdit = new QLineEdit(box); |
|
|
|
lineEdit->setMinimumHeight(30); |
|
|
|
// lineEdit->sizePolicy().setHorizontalStretch(1);
|
|
|
|
lineEdit->setSizePolicy(sizePolicy); |
|
|
|
lineEdit->setPlaceholderText(params[i]); |
|
|
|
layout->addWidget(lineEdit, rowcnt, i + 1, 1, 1); |
|
|
|
} |
|
|
|
} |