From c00b423d7a33bd441df47f83d26520da01ce6307 Mon Sep 17 00:00:00 2001 From: skythinker Date: Tue, 15 Feb 2022 13:24:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E5=88=97=E8=87=AA=E5=8A=A8=E5=88=97=E5=AE=BD=EF=BC=8C=E5=85=B6?= =?UTF-8?q?=E4=BD=99=E5=88=97=E5=A7=8B=E7=BB=88=E4=BF=9D=E6=8C=81=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=89=80=E8=B0=83=E6=95=B4=E7=9A=84=E5=88=97=E5=AE=BD?= =?UTF-8?q?=EF=BC=8C=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=97=E5=AE=BD=E8=AE=B0=E5=BD=95=EF=BC=9B=E5=87=8F=E5=B0=8F?= =?UTF-8?q?gdb=E6=8C=87=E4=BB=A4=E7=AD=89=E5=BE=85=E6=97=B6=E9=95=BF?= =?UTF-8?q?=EF=BC=8C=E5=B0=8F=E5=B9=85=E6=8F=90=E9=AB=98=E9=87=87=E6=A0=B7?= =?UTF-8?q?=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- gdbprocess.cpp | 2 +- mainwindow.cpp | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 26433fe..4c431e3 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ * 调试器模式理论上支持OpenOCD允许GDB连接的各种调试器及硬件芯片,如STLink、JLink、CMSIS-DAP等以及STM32全系列等 -* 调试器模式下采样约100Hz,串口模式下约70Hz +* 调试器模式下采样最高约100Hz,串口模式约80Hz * 图形化变量选择器 diff --git a/gdbprocess.cpp b/gdbprocess.cpp index 3153081..ef36654 100644 --- a/gdbprocess.cpp +++ b/gdbprocess.cpp @@ -17,7 +17,7 @@ QString GDBProcess::runCmd(const QString &cmd) process->write(cmd.toStdString().c_str()); QString res=""; do{ - process->waitForReadyRead(2); + process->waitForReadyRead(0); res+=process->readAllStandardOutput(); }while(!res.endsWith("(gdb) ")); return res; diff --git a/mainwindow.cpp b/mainwindow.cpp index aed0b82..8e21c17 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -352,12 +352,15 @@ void MainWindow::initTable() { redrawTable(); connect(tableModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(slotTableEdit(QModelIndex,QModelIndex))); - ui->tb_var->setModel(tableModel); + ui->tb_var->setModel(tableModel);//绑定表格model + ui->tb_var->horizontalHeader()->setMinimumSectionSize(150);//设置最小列宽150 } //重绘表格,设置表头并添加各变量信息 void MainWindow::redrawTable() { + QByteArray horiHeaderState=ui->tb_var->horizontalHeader()->saveState();//读出列宽数据 + tableModel->clear(); tableModel->setColumnCount(5);//设置表格为5列 tableModel->setHeaderData(0,Qt::Horizontal,"变量名");//设置表头 @@ -383,7 +386,9 @@ void MainWindow::redrawTable() } int lastRow=varList.size(); tableModel->setItem(lastRow,0,new QStandardItem(""));//末尾添加空行,用于用户添加变量 - ui->tb_var->resizeColumnsToContents();//根据表格内容自动调整列宽 + + ui->tb_var->horizontalHeader()->restoreState(horiHeaderState);//恢复列宽数据 + ui->tb_var->resizeColumnToContents(0);//根据第一列内容自动调整列宽 } //保存配置到指定路径的文件 @@ -393,6 +398,7 @@ void MainWindow::saveToFile(const QString &filename) settings.setIniCodec("GBK"); settings.beginGroup("Global");//写入全局配置 + settings.setValue("HoriHeader",ui->tb_var->horizontalHeader()->saveState()); settings.setValue("OpenocdMode",ui->rb_openocd->isChecked()); settings.setValue("SerialocdMode",ui->rb_serialocd->isChecked()); settings.setValue("Interface",ui->cb_interface->currentText()); @@ -420,6 +426,8 @@ void MainWindow::loadFromFile(const QString &filename) settings.setIniCodec("GBK"); settings.beginGroup("Global");//读取全局配置 + if(settings.contains("HoriHeader")) + ui->tb_var->horizontalHeader()->restoreState(settings.value("HoriHeader").toByteArray()); ui->rb_openocd->setChecked(settings.value("OpenocdMode",true).toBool()); ui->rb_serialocd->setChecked(settings.value("SerialocdMode",false).toBool()); ui->cb_interface->setCurrentText(settings.value("Interface").toString());