优化下拉框搜索,将科学计数法改为保留两位小数显示,可以正确识别日志中的科学计数法
This commit is contained in:
2024-09-14 10:37:03 +08:00
parent 19d21216e4
commit 53362d9373
4 changed files with 17 additions and 5 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 12.0.2, 2024-09-13T21:26:35. --> <!-- Written by QtCreator 12.0.2, 2024-09-14T08:27:16. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
@ -99,7 +99,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 5.12.0 (mingw73_64)</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 5.12.0 (mingw73_64)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 5.12.0 (mingw73_64)</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 5.12.0 (mingw73_64)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{edc54fcd-f681-4a0a-ba77-11a1a5c94a66}</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{edc54fcd-f681-4a0a-ba77-11a1a5c94a66}</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value> <value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
@ -255,7 +255,7 @@
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value> <value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Work/CQT/Test_01/build-log7-Qt_5_12_0_mingw73_64-Release</value> <value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Work/CQT/Test_01/build-log7-Qt_5_12_0_mingw73_64-Debug</value>
</valuemap> </valuemap>
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value> <value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap> </valuemap>

View File

@ -85,6 +85,7 @@ void MainWindow::addCombo(const QStringList &list) {
ui->comboBox->addItems(list); ui->comboBox->addItems(list);
//根据输入匹配下拉框 //根据输入匹配下拉框
Gloab::completer = new QCompleter(list); Gloab::completer = new QCompleter(list);
Gloab::completer->setFilterMode(Qt::MatchContains);
ui->comboBox->setCompleter(Gloab::completer); ui->comboBox->setCompleter(Gloab::completer);
} }

View File

@ -35,6 +35,9 @@ QCustPlot::QCustPlot(QVector<double> xData, QVector<double> yData, int jd, bool
QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText); QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
textTicker->addTicks(ticks, labels); textTicker->addTicks(ticks, labels);
ui->plot->yAxis->setTicker(textTicker); ui->plot->yAxis->setTicker(textTicker);
}else{
ui->plot->yAxis->setNumberFormat("f");
ui->plot->yAxis->setNumberPrecision(2);
} }
// 添加图形 // 添加图形

View File

@ -5,11 +5,19 @@ threadRead::threadRead(QObject *parent)
} }
bool threadRead::isNumeric(QString data) { bool threadRead::isNumeric(QString data) {
bool flag = false;
// 正则表达式匹配数字和可选的正负号 // 正则表达式匹配数字和可选的正负号
QRegularExpression pattern("^[+-]?([1-9][0-9]*|0)[.]?[0-9]*$"); QRegularExpression pattern("^[+-]?([1-9][0-9]*|0)[.]?[0-9]*$");
QRegularExpressionMatch patternMatch =pattern.match(data); QRegularExpressionMatch patternMatch =pattern.match(data);
// 使用std::regex_match来检查字符串是否完全匹配模式 if(patternMatch.hasMatch()){
return patternMatch.hasMatch(); flag = true;
}
QRegularExpression kexue("^[0-9].[0-9]e[+-][0-9][0-9]");
QRegularExpressionMatch kexueMatch =kexue.match(data);
if(kexueMatch.hasMatch()){
flag = true;
}
return flag;
} }
void threadRead::run() { void threadRead::run() {