Qt 实现简易串口助手

2023-11-03

界面预览:
在这里插入图片描述
代码如下:
.h文件

#pragma once

#include <QtWidgets/QMainWindow>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QTimer>

#include "ui_MainWin.h"

class MainWin : public QMainWindow
{
    Q_OBJECT

public:
    MainWin(QWidget *parent = Q_NULLPTR);
private:
    void initUi();
    void initConnect();
    void sendDataProcess();
    void disconnectPort();
private slots:
    void updateLocalTime();
    void checkTimeout();
    void handleSerialError(QSerialPort::SerialPortError error);

    void onOpenPort();
    void onSendData();
    void onReadData();
    void onTimedData(bool checked);
    void onReceiveAreaStyle(bool checked);
    void onChangeReceivedDataFormat(bool checked);
    void onClearSendData();
    void onClearReceivedData();
    void onStopDisplay(bool checked);
    void onOpenCalculator();
    void onTimeCycleTextFormat();
    void modifySendDataFormatSlot();
    void sendDataChangeSlot();
private:
    Ui::MainWinClass ui;
    QList<QSerialPortInfo> m_portInfo;  // 可用端口列表
    QList<QString> m_portNames;         // 可用端口列表
    QSerialPort* m_pSerial;             // 连接串口端口
    QTimer m_timer;                     // 更新当前系统时间
    QTimer m_timedSend;                 // 定时发送
    QTimer m_serialPortTimer;           // 定时检测端口是否连接
    QString m_textData;                 // 文本数据缓冲区
    QString m_hexData;                  // 十六进制数据缓冲区
    bool linkState = false;             // 端口连接状态
    qint64 receiveByte = 0;             // 记录接收字节数
    qint64 sendByte = 0;                // 记录发送字节数
};

.cpp文件

#include "MainWin.h"

#include <QMessageBox>
#include <QTextCodec>
#include <QDataStream>
#include <QListView>
#include <QProcess>
#include <QTime>
#include <QDebug>

#if _MSC_VER > 1600
#pragma execution_character_set("utf-8")
#endif // _MSC_VER > 1600

MainWin::MainWin(QWidget *parent)
    : QMainWindow(parent)
{
    ui.setupUi(this);
    initUi();
}

void MainWin::initUi()
{
    setWindowTitle("串口助手");
    setWindowIcon(QIcon(":/image/logo.png"));
    ui.serialStateBtn->setIconSize(QSize(30, 30));
    ui.serialStateBtn->setIcon(QIcon(":/image/closeSerial.png"));
    // 设置初始接收区为,绿字黑底
    ui.receiveTxb->setStyleSheet("background-color: rgb(0, 0, 0);"
        "color: rgb(0, 255, 0);");
    m_pSerial = new QSerialPort;
    // 更新显示时间
    connect(&m_timer, &QTimer::timeout, this, &MainWin::updateLocalTime);
    m_timer.start(1000);

    // 检测端口是否连接
    connect(&m_serialPortTimer, &QTimer::timeout, this, &MainWin::checkTimeout);
    m_serialPortTimer.start(1000);
    connect(m_pSerial, QOverload<QSerialPort::SerialPortError>::of(&QSerialPort::error), this, &MainWin::handleSerialError);

    // 定时发送
    connect(&m_timedSend, &QTimer::timeout, this, [=]() {
        if ((ui.sendTxd->toPlainText() == "") || (linkState == false))
            return;
        this->sendDataProcess();
        });
    // 周期范围1-1000000
    ui.cycleLd->setValidator(new QIntValidator(1, 1000000, this));

    // 为了使下拉条目样式起效
    ui.portNumCbx->setView(new QListView);
    ui.baudCbx->setView(new QListView);
    ui.dataBitCbx->setView(new QListView);
    ui.stopBitCbx->setView(new QListView);
    ui.parityBitCbx->setView(new QListView);

    initConnect();
}

void MainWin::initConnect()
{
    // 打开端口
    connect(ui.serialStateBtn, &QPushButton::clicked, this, &MainWin::onOpenPort);
    // 发送数据
    connect(ui.sendBtn, &QPushButton::clicked, this, &MainWin::onSendData);
    // 清空发送数据
    connect(ui.clearSendBtn, &QPushButton::clicked, this, &MainWin::onClearSendData);
    // 清空接收数据
    connect(ui.clearReceiveBtn, &QPushButton::clicked, this, &MainWin::onClearReceivedData);
    // 停止接收数据显示
    connect(ui.displayStateBtn, &QPushButton::clicked, this, &MainWin::onStopDisplay);
    // 定时发送数据
    connect(ui.timerChk, &QCheckBox::clicked, this, &MainWin::onTimedData);
    // 修改接收数据区样式
    connect(ui.receiveStyleChk, &QCheckBox::clicked, this, &MainWin::onReceiveAreaStyle);
    // 修改接收数据格式
    connect(ui.receiveFormatChk, &QCheckBox::clicked, this, &MainWin::onChangeReceivedDataFormat);
    // 修改接收数据格式
    connect(ui.sendFormatChk, &QCheckBox::clicked, this, &MainWin::modifySendDataFormatSlot);
    // 发送框数据变化
    connect(ui.sendTxd, &QTextEdit::textChanged, this, &MainWin::sendDataChangeSlot);
    // 打开计算器
    connect(ui.calculatorBtn, &QPushButton::clicked, this, &MainWin::onOpenCalculator);

    // 定时周期(文本格式)
    connect(ui.cycleLd, &QLineEdit::inputRejected, this, &MainWin::onTimeCycleTextFormat);
    connect(ui.cycleLd, &QLineEdit::textEdited, this, &MainWin::onTimeCycleTextFormat);
}

// 处理要发送的数据
void MainWin::sendDataProcess()
{
    if (ui.sendFormatChk->isChecked()) // 16进制
    {
        // 转换文本
        QString strHex = ui.sendTxd->toPlainText();
        strHex.remove(QRegExp("\\s"));  // 删除所有空格
        if (strHex.size() % 2 != 0)     // 奇数删掉最后一个字符
        {
            strHex = strHex.left(strHex.size() - 1);
        }

        // 是否加换行符
        if (ui.newLineChk->isChecked())
        {
            strHex += "0D 0A";
        }

        QByteArray text = QByteArray::fromHex(strHex.toUtf8());
        // 发送数据
        m_pSerial->write(text);
        m_pSerial->waitForBytesWritten();

        // 记录发送数据量
        sendByte += text.size();
        ui.sendByteLbl->setText("S:" + QString::number(sendByte));
    }
    else
    {
        QString data = ui.sendTxd->toPlainText();
        data.replace("\n", "\r\n");  // 将\n换成\r\n

        // 是否加换行符
        if (ui.newLineChk->isChecked())
        {
            data += "\r\n";
        }
        // 发送数据
        m_pSerial->write(data.toLocal8Bit());
        m_pSerial->waitForBytesWritten();

        // 记录发送数据量
        sendByte += data.toLocal8Bit().size();
        ui.sendByteLbl->setText("S:" + QString::number(sendByte));
    }
}

void MainWin::disconnectPort()
{
    ui.portNumCbx->setEnabled(true);
    ui.baudCbx->setEnabled(true);
    ui.dataBitCbx->setEnabled(true);
    ui.stopBitCbx->setEnabled(true);
    ui.parityBitCbx->setEnabled(true);
    linkState = false;
    m_pSerial->close();
    ui.serialStateBtn->setText("打开串口");
    ui.serialStateBtn->setIcon(QIcon(":/image/closeSerial.png"));
}

// 显示当前时间
void MainWin::updateLocalTime()
{
    ui.localTimeLbl->setText("当前时间:" + QTime::currentTime().toString("hh:mm:ss"));
}

// 串口连接中断开错误
void MainWin::handleSerialError(QSerialPort::SerialPortError error)
{
    //QSerialPort::ResourceError
    qDebug() << error;
    if (error == QSerialPort::PermissionError) {
        disconnectPort();
    }
}

// 检测端口是否断开
void MainWin::checkTimeout()
{
    // 获取可用端口
    QList<QSerialPortInfo> portInfo = QSerialPortInfo::availablePorts();
    QList<QString> portNames;
    // 添加新增的端口
    foreach(QSerialPortInfo info, portInfo)
    {
        portNames.append(info.portName());
        // 跳过重复的
        if (-1 == ui.portNumCbx->findText(info.portName()))
        {
            ui.portNumCbx->addItem(info.portName());
            m_portNames.append(info.portName());
        }
    }
    // 移除已不存在的端口
    foreach(QString portName, m_portNames)
    {
        if (!portNames.contains(portName))
        {
            m_portNames.removeOne(portName);
            ui.portNumCbx->removeItem(ui.portNumCbx->findText(portName));
        }
    }
}

// 打开端口
void MainWin::onOpenPort()
{
    if (linkState == false)
    {
        // 设置端口号
        m_pSerial->setPort(QSerialPortInfo(ui.portNumCbx->currentText()));
        // 设置波特率
        m_pSerial->setBaudRate(ui.baudCbx->currentText().toInt());
        // 设置数据位
        switch (ui.dataBitCbx->currentIndex())
        {
        default:
        case 0:
            m_pSerial->setDataBits(QSerialPort::Data8);
            break;
        case 1:
            m_pSerial->setDataBits(QSerialPort::Data7);
            break;
        case 2:
            m_pSerial->setDataBits(QSerialPort::Data6);
            break;
        case 3:
            m_pSerial->setDataBits(QSerialPort::Data5);
            break;
        }
        // 设置停止位
        switch (ui.stopBitCbx->currentIndex())
        {
        default:
        case 0:
            m_pSerial->setStopBits(QSerialPort::OneStop);
            break;
        case 1:
            m_pSerial->setStopBits(QSerialPort::OneAndHalfStop);
            break;
        case 2:
            m_pSerial->setStopBits(QSerialPort::TwoStop);
            break;
        }
        // 设置校验位
        switch (ui.parityBitCbx->currentIndex())
        {
            // 无校验
        default:
        case 0:
            m_pSerial->setParity(QSerialPort::NoParity);
            break;
            // 奇校验
        case 1:
            m_pSerial->setParity(QSerialPort::OddParity);
            break;
            //偶校验
        case 2:
            m_pSerial->setParity(QSerialPort::EvenParity);
            break;
        }
        if (!m_pSerial->open(QIODevice::ReadWrite))
        {
            //qDebug()<<m_pSerial->error();
            //QMessageBox::critical(this, "错误提示", "串口打开失败!!!\n串口被占用或者其它错误", "确定");
            QMessageBox msgbox(this);
            msgbox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::Dialog);
            msgbox.setWindowTitle("错误");
            msgbox.setIcon(QMessageBox::Critical);
            msgbox.setText("串口打开失败!!!\n串口被占用或者其它错误");
            msgbox.addButton("确定", QMessageBox::AcceptRole);
            msgbox.setStyleSheet("QMessageBox {background-color: rgb(240,240,240);}QMessageBox QLabel#qt_msgbox_label{min-width: 180px;min-height: 40px;background-color:transparent;}");
            msgbox.exec();
            return;
        }
        ui.portNumCbx->setEnabled(false);
        ui.baudCbx->setEnabled(false);
        ui.dataBitCbx->setEnabled(false);
        ui.stopBitCbx->setEnabled(false);
        ui.parityBitCbx->setEnabled(false);
        connect(m_pSerial, &QSerialPort::readyRead, this, &MainWin::onReadData);
        ui.serialStateBtn->setText("关闭串口");
        ui.serialStateBtn->setIcon(QIcon(":/image/openSerial.png"));
        linkState = true;
    }
    else
    {
        disconnectPort();
    }
}

// 发送数据
void MainWin::onSendData()
{
    // 无连接
    if (linkState == false)
    {
        //QMessageBox::critical(this, "错误提示", "串口没有打开!!!\n请打开串口", "确定");
        QMessageBox msgbox(this);
        msgbox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::Dialog);
        msgbox.setWindowTitle("错误");
        msgbox.setIcon(QMessageBox::Critical);
        msgbox.setText("串口没有打开!!!\n请打开串口");
        msgbox.addButton("确定", QMessageBox::AcceptRole);
        msgbox.setStyleSheet("QMessageBox {background-color: rgb(240,240,240);}QMessageBox QLabel#qt_msgbox_label{min-width: 180px;min-height: 40px;background-color:transparent;}");
        msgbox.exec();
        return;
    }
    this->sendDataProcess();
}

// 接收数据
void MainWin::onReadData()
{
    QByteArray msg = m_pSerial->readAll();
    // 记录接收数据量
    receiveByte += msg.size();
    ui.receiveByteLbl->setText("R:" + QString::number(receiveByte));
    // 停止显示
    if (ui.displayStateBtn->isChecked())
        return;

    // 将数据写入文本缓冲区 msg编码是本地编码(ANSI) 通过fromLocal8Bit()解码成Unicode(UTF-16)
    QString textMsg(QString::fromLocal8Bit(msg));
    //qDebug()<<textMsg;
    m_textData.append(textMsg);

    // 将数据写入十六进制缓冲区
    QString hexMsg;
    //QDataStream out(&msg, QIODevice::ReadWrite);
    //while (!out.atEnd())
    //{
    //    qint8 ch;
    //    out >> ch;
    //    hexMsg += QString("%1 ").arg(ch & 0xff, 2, 16, QLatin1Char('0'));
    //}
    //hexMsg = hexMsg.toUpper();// 转成大写

    hexMsg = msg.toHex(' ').toUpper();
    hexMsg.append(' ');
    m_hexData.append(hexMsg); 

    // 将光标移动到文本末尾,再插入数据
    //QTextCursor cursor = ui.receiveTextBrowser->textCursor();
    //cursor.movePosition(QTextCursor::End);
    //ui.receiveTextBrowser->setTextCursor(cursor);
    ui.receiveTxb->moveCursor(QTextCursor::End);

    // 十六进制显示
    if (ui.receiveFormatChk->isChecked())
    {
        ui.receiveTxb->insertPlainText(hexMsg);
    }
    else//文本显示
    {
        //转码并显示
        //ui->receiveTextBrowser->append(textMsg);  // 会自动加换行符
        ui.receiveTxb->insertPlainText(textMsg);
    }

    // 将光标移动到文本末尾
    ui.receiveTxb->moveCursor(QTextCursor::End);
}

// 定时发送数据
void MainWin::onTimedData(bool checked)
{
    if (checked)
    {
        int msec = ui.cycleLd->text().toInt();
        m_timedSend.start(msec);
        ui.cycleLd->setEnabled(false);
    }
    else
    {
        m_timedSend.stop();
        ui.cycleLd->setEnabled(true);
    }
}

// 接收区样式
void MainWin::onReceiveAreaStyle(bool checked)
{
    // 是否是白底黑字
    if (checked == true)
    {
        ui.receiveTxb->setStyleSheet("background-color: rgb(255, 255, 255);"
            "color: rgb(0, 0, 0);");
    }
    else
    {
        ui.receiveTxb->setStyleSheet("background-color: rgb(0, 0, 0);"
            "color: rgb(0, 255, 0);");
    }
}

// 更改接收数据格式
void MainWin::onChangeReceivedDataFormat(bool checked)
{
    // 清空使光标回到起始点
    ui.receiveTxb->clear();
    // 十六进制显示
    if (checked)
    {
        ui.receiveTxb->insertPlainText(m_hexData);
    }
    else// 文本显示
    {
        // 转码并显示
        ui.receiveTxb->insertPlainText(m_textData);
    }
}

// 清空发送数据
void MainWin::onClearSendData()
{
    sendByte = 0;
    ui.sendByteLbl->setText("S:" + QString::number(sendByte));
    ui.sendTxd->clear();
}

// 清空接收数据
void MainWin::onClearReceivedData()
{
    receiveByte = 0;
    ui.receiveByteLbl->setText("R:" + QString::number(receiveByte));
    ui.receiveTxb->clear();
    m_textData.clear();
    m_hexData.clear();
}

// 停止显示
void MainWin::onStopDisplay(bool checked)
{
    if (checked)
    {
        ui.displayStateBtn->setText("继续显示");
    }
    else
    {
        ui.displayStateBtn->setText("停止显示");
    }
}

// 定时周期格式
void MainWin::onTimeCycleTextFormat()
{
    if (ui.cycleLd->hasAcceptableInput() == false)
    {
        //QMessageBox::warning(this, "提示", "输入格式不正确!\n请输入数字(1-1000000)", "确定");
        QMessageBox msgbox(this);
        msgbox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::Dialog );
        msgbox.setWindowTitle("提示");
        msgbox.setIcon(QMessageBox::Warning);
        msgbox.setText("输入格式不正确!\n请输入数字(1-1000000)");
        msgbox.addButton("确定", QMessageBox::AcceptRole);
        msgbox.setStyleSheet("QMessageBox {background-color: rgb(240,240,240);}QMessageBox QLabel#qt_msgbox_label{min-width: 180px;min-height: 40px;background-color:transparent;}");
        msgbox.exec();
        ui.cycleLd->setText("1000");
    }
}

// 修改发送区数据
void MainWin::modifySendDataFormatSlot()
{
    if (ui.sendFormatChk->isChecked()) 
    {
        // 转成16进制
        QString strText = ui.sendTxd->toPlainText().replace('\n', "\r\n");
        QByteArray hex = strText.toLocal8Bit().toHex(' ').toUpper();
        ui.sendTxd->setPlainText(hex);
    }
    else
    {
        // 转成文本
        QString strHex = ui.sendTxd->toPlainText();
        strHex.remove(QRegExp("\\s"));  // 删除所有空格
        if (strHex.size() % 2 != 0)     // 奇数删掉最后一个字符
        {
            strHex = strHex.left(strHex.size() - 1);
        }
        QByteArray text = QByteArray::fromHex(strHex.toUtf8());
        ui.sendTxd->setPlainText(QString::fromLocal8Bit(text));
    }
}

void MainWin::sendDataChangeSlot()
{
    if (ui.sendFormatChk->isChecked())
    {  
        QString data = ui.sendTxd->toPlainText();
        if (data.isEmpty())
                return;

        QRegExp rx("[0-9a-fA-F ]+$");
        if (!rx.exactMatch(data))
        {
            ui.sendTxd->textCursor().deletePreviousChar();  //删除光标前的字符
            QMessageBox msgbox(this);
            msgbox.setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::Dialog);
            msgbox.setWindowTitle("提示");
            msgbox.setText("请输入正确格式0-9a-fA-F 例如 01 0a 0b");
            msgbox.addButton("确定", QMessageBox::AcceptRole);
            msgbox.setStyleSheet("QMessageBox {background-color: rgb(240,240,240);}QMessageBox QLabel#qt_msgbox_label{min-width: 310px;min-height: 40px;background-color:transparent;}");
            msgbox.exec();
        }
    }
}

// 打开计算器
void MainWin::onOpenCalculator()
{
    QProcess::startDetached("calc\n");
}

.ui文件
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWinClass</class>
 <widget class="QMainWindow" name="MainWinClass">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>910</width>
    <height>740</height>
   </rect>
  </property>
  <property name="minimumSize">
   <size>
    <width>910</width>
    <height>740</height>
   </size>
  </property>
  <property name="windowTitle">
   <string>MainWin</string>
  </property>
  <property name="styleSheet">
   <string notr="true">QWidget{
	color:  #000000;
	font:  16px &quot;SimHei&quot;;
}
QComboBox{
	 padding-left: 8px;
}
 QAbstractItemView {
    outline: 0;
    font: 16px &quot;SimHei&quot;;
	min-height:36px;
}
QAbstractItemView::item {
	color: rgb(0, 0, 0);
	background-color: rgb(255, 255, 255);
    padding-left: 5px;
 	min-height:  28px;
    min-width:  60px;
}
QAbstractItemView::item:selected {
	background-color: rgb(204, 228, 247);
}

QScrollArea{
   	border-radius: 2px;
	border: 2px solid rgb(0, 0, 0);
}

QScrollBar:vertical{
    border: none;
    width: 20px;
    margin: 16px 0 16px 0;
}
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
    background: #f0f0f0;
}
QScrollBar::handle:vertical {
    /*background: transparent;*/
	background: #cccccc;
    min-height: 60px;
    border: none;
}
QScrollBar:handle:vertical:hover {
	background: #a6a6a6;
}

QScrollBar::add-line:vertical {
    border: 0px solid grey;
    background: #f0f0f0;
    height: 16px;
    subcontrol-position: bottom;
    subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical {
    border: 0px solid grey;
    background: #f0f0f0;
    height: 16px;
    subcontrol-position: top;
    subcontrol-origin: margin;
}
QScrollBar::sub-line:vertical:hover,QScrollBar::add-line:vertical:hover
{
	background: #dadada;
}
QScrollBar::up-arrow:vertical { 
	border-image: url(:/image/scrollbarUp_default.png);
}
QScrollBar::down-arrow:vertical {
	border-image: url(:/image/scrollbarDown_default.png);	
}
QScrollBar::up-arrow:vertical:pressed { 
	border-image: url(:/image/scrollbarUp_clicked.png);
	background: #646464;
}
QScrollBar::down-arrow:vertical:pressed  {
	border-image: url(:/image/scrollbarDown_clicked.png);
	background: #646464;	
}
</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <layout class="QVBoxLayout" name="verticalLayout_3">
    <property name="spacing">
     <number>6</number>
    </property>
    <property name="leftMargin">
     <number>8</number>
    </property>
    <property name="topMargin">
     <number>2</number>
    </property>
    <property name="rightMargin">
     <number>8</number>
    </property>
    <property name="bottomMargin">
     <number>2</number>
    </property>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout_2">
      <item>
       <widget class="QTextBrowser" name="receiveTxb">
        <property name="font">
         <font>
          <family>SimHei</family>
          <pointsize>-1</pointsize>
          <weight>50</weight>
          <italic>false</italic>
          <bold>false</bold>
         </font>
        </property>
        <property name="focusPolicy">
         <enum>Qt::NoFocus</enum>
        </property>
        <property name="verticalScrollBarPolicy">
         <enum>Qt::ScrollBarAlwaysOn</enum>
        </property>
       </widget>
      </item>
      <item>
       <widget class="QGroupBox" name="groupBox_7">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
        <property name="minimumSize">
         <size>
          <width>245</width>
          <height>0</height>
         </size>
        </property>
        <property name="maximumSize">
         <size>
          <width>240</width>
          <height>16777215</height>
         </size>
        </property>
        <property name="font">
         <font>
          <family>SimHei</family>
          <pointsize>-1</pointsize>
          <weight>50</weight>
          <italic>false</italic>
          <bold>false</bold>
         </font>
        </property>
        <property name="styleSheet">
         <string notr="true">QGroupBox{
	font-size: 20px;
}</string>
        </property>
        <property name="title">
         <string>串口配置</string>
        </property>
        <property name="flat">
         <bool>false</bool>
        </property>
        <property name="checkable">
         <bool>false</bool>
        </property>
        <layout class="QVBoxLayout" name="verticalLayout">
         <property name="leftMargin">
          <number>8</number>
         </property>
         <property name="topMargin">
          <number>2</number>
         </property>
         <property name="rightMargin">
          <number>2</number>
         </property>
         <property name="bottomMargin">
          <number>0</number>
         </property>
         <item>
          <layout class="QGridLayout" name="gridLayout">
           <item row="0" column="1">
            <widget class="QComboBox" name="portNumCbx">
             <property name="minimumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
            </widget>
           </item>
           <item row="2" column="1">
            <widget class="QComboBox" name="dataBitCbx">
             <property name="minimumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <item>
              <property name="text">
               <string>8</string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>7</string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>6</string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>5</string>
              </property>
             </item>
            </widget>
           </item>
           <item row="4" column="1">
            <widget class="QComboBox" name="parityBitCbx">
             <property name="minimumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <item>
              <property name="text">
               <string></string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>奇校验</string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>偶校验</string>
              </property>
             </item>
            </widget>
           </item>
           <item row="2" column="0">
            <widget class="QLabel" name="label_9">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>数据位:</string>
             </property>
            </widget>
           </item>
           <item row="3" column="1">
            <widget class="QComboBox" name="stopBitCbx">
             <property name="minimumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <item>
              <property name="text">
               <string>1</string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>1.5</string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>2</string>
              </property>
             </item>
            </widget>
           </item>
           <item row="1" column="0">
            <widget class="QLabel" name="label_8">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>波特率:</string>
             </property>
            </widget>
           </item>
           <item row="3" column="0">
            <widget class="QLabel" name="label_10">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>停止位:</string>
             </property>
            </widget>
           </item>
           <item row="4" column="0">
            <widget class="QLabel" name="label_11">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>校验位:</string>
             </property>
            </widget>
           </item>
           <item row="0" column="0">
            <widget class="QLabel" name="label_7">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>端口号:</string>
             </property>
            </widget>
           </item>
           <item row="1" column="1">
            <widget class="QComboBox" name="baudCbx">
             <property name="minimumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="currentIndex">
              <number>0</number>
             </property>
             <item>
              <property name="text">
               <string>115200</string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>76800</string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>38400</string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>9600</string>
              </property>
             </item>
             <item>
              <property name="text">
               <string>4800</string>
              </property>
             </item>
            </widget>
           </item>
           <item row="5" column="0">
            <widget class="QLabel" name="label_12">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>串口操作:</string>
             </property>
            </widget>
           </item>
           <item row="5" column="1">
            <widget class="QPushButton" name="serialStateBtn">
             <property name="minimumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>打开串口</string>
             </property>
             <property name="icon">
              <iconset resource="MainWin.qrc">
               <normaloff>:/image/closeSerial.png</normaloff>:/image/closeSerial.png</iconset>
             </property>
             <property name="iconSize">
              <size>
               <width>30</width>
               <height>30</height>
              </size>
             </property>
            </widget>
           </item>
          </layout>
         </item>
         <item>
          <layout class="QHBoxLayout" name="horizontalLayout_5">
           <item>
            <widget class="QPushButton" name="displayStateBtn">
             <property name="minimumSize">
              <size>
               <width>0</width>
               <height>36</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>停止显示</string>
             </property>
             <property name="checkable">
              <bool>true</bool>
             </property>
            </widget>
           </item>
           <item>
            <widget class="QPushButton" name="clearReceiveBtn">
             <property name="sizePolicy">
              <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
             </property>
             <property name="minimumSize">
              <size>
               <width>120</width>
               <height>36</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>清空接收区</string>
             </property>
            </widget>
           </item>
          </layout>
         </item>
         <item>
          <layout class="QGridLayout" name="gridLayout_2">
           <property name="spacing">
            <number>6</number>
           </property>
           <item row="0" column="0">
            <widget class="QCheckBox" name="receiveFormatChk">
             <property name="minimumSize">
              <size>
               <width>110</width>
               <height>28</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
               <width>110</width>
               <height>28</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>16进制显示</string>
             </property>
            </widget>
           </item>
           <item row="0" column="1">
            <widget class="QCheckBox" name="receiveStyleChk">
             <property name="minimumSize">
              <size>
               <width>100</width>
               <height>28</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
               <width>100</width>
               <height>28</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>白底黑字</string>
             </property>
             <property name="checked">
              <bool>false</bool>
             </property>
             <property name="tristate">
              <bool>false</bool>
             </property>
            </widget>
           </item>
           <item row="0" column="2">
            <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>
          </layout>
         </item>
         <item>
          <widget class="Line" name="line">
           <property name="frameShadow">
            <enum>QFrame::Sunken</enum>
           </property>
           <property name="lineWidth">
            <number>2</number>
           </property>
           <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
          </widget>
         </item>
         <item>
          <layout class="QGridLayout" name="gridLayout_3">
           <property name="spacing">
            <number>6</number>
           </property>
           <item row="0" column="1">
            <widget class="QCheckBox" name="timerChk">
             <property name="minimumSize">
              <size>
               <width>100</width>
               <height>28</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
               <width>100</width>
               <height>28</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>定时发送</string>
             </property>
            </widget>
           </item>
           <item row="0" column="2">
            <layout class="QHBoxLayout" name="horizontalLayout_4">
             <property name="spacing">
              <number>2</number>
             </property>
             <item>
              <widget class="QLabel" name="label">
               <property name="sizePolicy">
                <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
               <property name="minimumSize">
                <size>
                 <width>45</width>
                 <height>0</height>
                </size>
               </property>
               <property name="maximumSize">
                <size>
                 <width>45</width>
                 <height>16777215</height>
                </size>
               </property>
               <property name="font">
                <font>
                 <family>SimHei</family>
                 <pointsize>-1</pointsize>
                 <weight>50</weight>
                 <italic>false</italic>
                 <bold>false</bold>
                </font>
               </property>
               <property name="text">
                <string>周期:</string>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QLineEdit" name="cycleLd">
               <property name="minimumSize">
                <size>
                 <width>50</width>
                 <height>24</height>
                </size>
               </property>
               <property name="maximumSize">
                <size>
                 <width>40</width>
                 <height>24</height>
                </size>
               </property>
               <property name="font">
                <font>
                 <family>SimHei</family>
                 <pointsize>-1</pointsize>
                 <weight>50</weight>
                 <italic>false</italic>
                 <bold>false</bold>
                </font>
               </property>
               <property name="inputMask">
                <string/>
               </property>
               <property name="text">
                <string>1000</string>
               </property>
               <property name="maxLength">
                <number>10</number>
               </property>
              </widget>
             </item>
             <item>
              <widget class="QLabel" name="label_2">
               <property name="minimumSize">
                <size>
                 <width>20</width>
                 <height>0</height>
                </size>
               </property>
               <property name="maximumSize">
                <size>
                 <width>20</width>
                 <height>16777215</height>
                </size>
               </property>
               <property name="font">
                <font>
                 <family>SimHei</family>
                 <pointsize>-1</pointsize>
                 <weight>50</weight>
                 <italic>false</italic>
                 <bold>false</bold>
                </font>
               </property>
               <property name="text">
                <string>ms</string>
               </property>
               <property name="alignment">
                <set>Qt::AlignCenter</set>
               </property>
              </widget>
             </item>
            </layout>
           </item>
           <item row="2" column="2">
            <widget class="QCheckBox" name="newLineChk">
             <property name="minimumSize">
              <size>
               <width>110</width>
               <height>28</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
               <width>110</width>
               <height>28</height>
              </size>
             </property>
             <property name="font">
              <font>
               <family>SimHei</family>
               <pointsize>-1</pointsize>
               <weight>50</weight>
               <italic>false</italic>
               <bold>false</bold>
              </font>
             </property>
             <property name="text">
              <string>自动换行</string>
             </property>
             <property name="checked">
              <bool>true</bool>
             </property>
            </widget>
           </item>
           <item row="2" column="1">
            <widget class="QCheckBox" name="sendFormatChk">
             <property name="minimumSize">
              <size>
               <width>110</width>
               <height>28</height>
              </size>
             </property>
             <property name="text">
              <string>16进制发送</string>
             </property>
            </widget>
           </item>
          </layout>
         </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>
        </layout>
       </widget>
      </item>
     </layout>
    </item>
    <item>
     <widget class="QWidget" name="widget_8" native="true">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
      <property name="minimumSize">
       <size>
        <width>0</width>
        <height>120</height>
       </size>
      </property>
      <property name="maximumSize">
       <size>
        <width>16777215</width>
        <height>120</height>
       </size>
      </property>
      <layout class="QHBoxLayout" name="horizontalLayout">
       <property name="leftMargin">
        <number>0</number>
       </property>
       <property name="topMargin">
        <number>0</number>
       </property>
       <property name="rightMargin">
        <number>0</number>
       </property>
       <property name="bottomMargin">
        <number>0</number>
       </property>
       <item>
        <widget class="QTextEdit" name="sendTxd">
         <property name="verticalScrollBarPolicy">
          <enum>Qt::ScrollBarAlwaysOn</enum>
         </property>
        </widget>
       </item>
       <item>
        <layout class="QVBoxLayout" name="verticalLayout_2" stretch="2,1,2">
         <item>
          <widget class="QPushButton" name="sendBtn">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
             <horstretch>0</horstretch>
             <verstretch>0</verstretch>
            </sizepolicy>
           </property>
           <property name="maximumSize">
            <size>
             <width>16777215</width>
             <height>36</height>
            </size>
           </property>
           <property name="font">
            <font>
             <family>SimHei</family>
             <pointsize>-1</pointsize>
             <weight>50</weight>
             <italic>false</italic>
             <bold>false</bold>
            </font>
           </property>
           <property name="text">
            <string>发送</string>
           </property>
          </widget>
         </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>
         <item>
          <widget class="QPushButton" name="clearSendBtn">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
             <horstretch>0</horstretch>
             <verstretch>0</verstretch>
            </sizepolicy>
           </property>
           <property name="minimumSize">
            <size>
             <width>107</width>
             <height>0</height>
            </size>
           </property>
           <property name="maximumSize">
            <size>
             <width>16777215</width>
             <height>36</height>
            </size>
           </property>
           <property name="font">
            <font>
             <family>SimHei</family>
             <pointsize>-1</pointsize>
             <weight>50</weight>
             <italic>false</italic>
             <bold>false</bold>
            </font>
           </property>
           <property name="text">
            <string>清空发送区</string>
           </property>
          </widget>
         </item>
        </layout>
       </item>
      </layout>
     </widget>
    </item>
    <item>
     <widget class="QWidget" name="widget" native="true">
      <property name="font">
       <font>
        <family>SimHei</family>
        <pointsize>-1</pointsize>
        <weight>50</weight>
        <italic>false</italic>
        <bold>false</bold>
       </font>
      </property>
      <layout class="QHBoxLayout" name="horizontalLayout_3">
       <property name="leftMargin">
        <number>0</number>
       </property>
       <property name="topMargin">
        <number>0</number>
       </property>
       <property name="rightMargin">
        <number>0</number>
       </property>
       <property name="bottomMargin">
        <number>0</number>
       </property>
       <item>
        <widget class="QPushButton" name="calculatorBtn">
         <property name="minimumSize">
          <size>
           <width>28</width>
           <height>28</height>
          </size>
         </property>
         <property name="maximumSize">
          <size>
           <width>28</width>
           <height>28</height>
          </size>
         </property>
         <property name="toolTip">
          <string>计算器</string>
         </property>
         <property name="statusTip">
          <string/>
         </property>
         <property name="whatsThis">
          <string/>
         </property>
         <property name="styleSheet">
          <string notr="true">QPushButton{
	border-image: url(:/image/calculator.png);
}
QPushButton:pressed{
	border: 1px solid reg(0,0,0);
}</string>
         </property>
         <property name="text">
          <string/>
         </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="QLabel" name="sendByteLbl">
         <property name="minimumSize">
          <size>
           <width>200</width>
           <height>0</height>
          </size>
         </property>
         <property name="maximumSize">
          <size>
           <width>200</width>
           <height>16777215</height>
          </size>
         </property>
         <property name="font">
          <font>
           <family>SimHei</family>
           <pointsize>-1</pointsize>
           <weight>50</weight>
           <italic>false</italic>
           <bold>false</bold>
          </font>
         </property>
         <property name="text">
          <string>S:0</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>
       <item>
        <widget class="QLabel" name="receiveByteLbl">
         <property name="minimumSize">
          <size>
           <width>200</width>
           <height>0</height>
          </size>
         </property>
         <property name="maximumSize">
          <size>
           <width>200</width>
           <height>16777215</height>
          </size>
         </property>
         <property name="font">
          <font>
           <family>SimHei</family>
           <pointsize>-1</pointsize>
           <weight>50</weight>
           <italic>false</italic>
           <bold>false</bold>
          </font>
         </property>
         <property name="text">
          <string>R:0</string>
         </property>
        </widget>
       </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>
       <item>
        <widget class="QLabel" name="localTimeLbl">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
           <horstretch>0</horstretch>
           <verstretch>0</verstretch>
          </sizepolicy>
         </property>
         <property name="minimumSize">
          <size>
           <width>160</width>
           <height>0</height>
          </size>
         </property>
         <property name="maximumSize">
          <size>
           <width>160</width>
           <height>16777215</height>
          </size>
         </property>
         <property name="font">
          <font>
           <family>SimHei</family>
           <pointsize>-1</pointsize>
           <weight>50</weight>
           <italic>false</italic>
           <bold>false</bold>
          </font>
         </property>
         <property name="text">
          <string>当前时间:00:00:00</string>
         </property>
        </widget>
       </item>
      </layout>
     </widget>
    </item>
   </layout>
  </widget>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources>
  <include location="MainWin.qrc"/>
 </resources>
 <connections/>
</ui>

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Qt 实现简易串口助手 的相关文章

随机推荐

  • minicom安装、配置和使用

    在开发过程中 我们经常需要通过串口连接Android开发板的底层系统 Linux QNX 等 minicom是一个常用串口连接终端软件 在命令行终端下通过文本界面进行操作使用 安装 sudo apt install minicom 配置 首
  • BufferedReader与FileReader及FileInputStream

    BufferedReader 是缓冲字符输入流 它继承于Reader BufferedReader 的作用是为其他字符输入流添加一些缓冲功能 BufferedReader的作用 从字符输入流中读取文本 缓冲各个字符 从而实现字符 数组和行的
  • C# Ocr离线式识别,文字提取,(附源码下载)

    源代码下载 效果图 文字内容提取后填充 JObject obj ocr GeneralBasic bt ops this richTextBox1 Text string str if obj Count gt 0 JArray jo JA
  • LeetCode - 移除元素

    一 题目描述 给定一个数组 nums 和一个值 val 你需要原地移除所有数值等于 val 的元素 返回移除后数组的新长度 不要使用额外的数组空间 你必须在原地修改输入数组并在使用 O 1 额外空间的条件下完成 元素的顺序可以改变 你不需要
  • GBase8a MPP Cluster 安装部署——操作系统配置建议

    编写目的 本文档面向GBase 8a产品的售后人员 用户使用人员 以及广大GBase 8a感兴趣的技术人员 以便用于指导其更好的完成GBase8a MPP Cluster 安装部署工作 对硬件配置 网络环境 操作系统及软件配置等系统实施过程
  • vue 接口数据返回之后再渲染页面_Vue怎么让数据请求成功以后再渲染页面?

    需求如下 进入页面有一个检测按钮 点击即可向后端请求数据 进入页面如果不点击检测 则显示如下 点击检测 如果返回的是正常的状态则显示 如果返回的状态是异常 则显示 目前有个BUG 就是点击检测的时候 先从变为 然后马上变为 因为逻辑里面我是
  • IJCAI2023 Summary Reject公布

    点击文末公众号卡片 找对地方 轻松参会 北京时间2023年2月25日上午6点四十左右 cmt上状态已变 分为awaiting list 和reject 此前不少人预测2月24日晚上八点或凌晨两点左右出 截至2023年2月25日 7 16 a
  • 调用TransactionAspectSupport.currentTransactionStatus().setRollbackOnly()时遇到的一些问题

    之前在其他地方写的 一直要求手机验证 之前能跳过 麻烦点就麻烦点了 今天编辑文章的时候直接不能改了 无奈 如果手动调用 TransactionAspectSupport currentTransactionStatus setRollbac
  • mybatis获取插入数据时自动生成的主键id

    mapper文件 void insert Map
  • LaTeX

    简介 首先要介绍一下我用的Visio文件转为 eps的办法 vsd 文件 利用Visio打开 然后另存为 选择存为 pdf文件 pdf文件 利用Inkscape打开 然后另存为 选择存为 eps格式 之前一直用visio2010版 然后按照
  • 【React+TS】从零开始搭建react+typescript+router+redux+less+px2rem自适应+axios反向代理+别名@+Antd-mobile

    一 通过create react app脚手架创建项目 npx create react app testproject template typescript 在vscode中打开项目 可以看到顺利生成了react项目且组件的后缀为tsx
  • Java web项目创建笔记23 之《spring整合xxl-job》

    xxl job是一款功能强大的分布式任务调度系统 部署方法按照官网写的说明即可 https www xuxueli com xxl job 1 下载release版本代码 https github com xuxueli xxl job r
  • 先电Openstack云平台搭建【超级详细】【附带镜像】

    前言 大二上学期学习Openstack 苦于百度与CSDN上没有对应版本的教程 学的十分艰难 在此 将我的Openstack云平台搭建过程写出 留给新手学习 准备工作 VMware Workstation Pro 虚拟机 我使用版本 15
  • C++模板,模板具体化,特例化

    1 模板重载原则 函数同名 重载 时 调用优先级通常为 普通函数 gt 显式具体化 template specilazation gt 显式实例化 gt 一般模版函数 但更一般而言 有两条规则 1 gt 如果各自函数形参和调用处的实参 并非
  • Java锁的基本用法

    文章目录 Java锁的基本用法 synchronized和lock synchronized 首先在没有加锁的情况下 加锁的情况 Lock 首先在没有加锁的情况下 加锁的情况下 线程的通信 synchronized 通过wait和notif
  • Js 代替eval的方法 字符串转对象

    js中常用eval 函数将一个字符串当作一个JavaScript表达式一样去执行 但在安全漏洞上是存在隐患的 现找到eval函数的替代方法 let a custId 9860131056 custName custAdd const res
  • Apache Flink 使用DataStream API进行数据处理

    问题导读1 流处理和批处理分别入口是什么 2 对于本地和远程运行程序 都可以使用哪个函数 3 Flink数据源分为哪两类 4 Flink DataStream和DataSet source都是基于什么格式 5 Flink中kafka sou
  • 货币兑换(指针与常量)

    货币兑换 指针与常量 题目描述 设定以下汇率常量 美元汇率为6 2619 表示1美元兑换6 2619元人民币 欧元汇率为6 6744 表示1欧元兑换6 6744元人民币 日元汇率为0 0516 表示1元日元兑换0 0516元人民币 港币汇率
  • matlab 矩阵列乘系数,matlab 给某一列乘上一个系数

    矩阵M是一个 mxn 的矩阵 现在要给M矩阵的第一列都要乘上10 使其第一列扩大10倍 那肿么做呢 我第一时间用的是 M 1 M 1 10 错误的 但是这个错了 结果是不对的 这里要用点乘才行 所以正确的写法是 M 1 M 1 10 正确写
  • Qt 实现简易串口助手

    界面预览 代码如下 h文件 pragma once include