X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fanalogsignal.cpp;h=d128e1c37ba354753277cac9956644136d01cd57;hb=1ed73ebd60336c7b12ee1807644dca719cb9835b;hp=8c0dacd26fa52f9579c00efb4124a2f6f6afa9bf;hpb=fa8d0fcb4cff4f19943fe3ff152dc1428b400b01;p=pulseview.git diff --git a/pv/views/trace/analogsignal.cpp b/pv/views/trace/analogsignal.cpp index 8c0dacd2..d128e1c3 100644 --- a/pv/views/trace/analogsignal.cpp +++ b/pv/views/trace/analogsignal.cpp @@ -1100,13 +1100,20 @@ void AnalogSignal::on_conv_threshold_changed(int index) // https://txt2re.com/index-c++.php3?s=0.1V&1&-13 QString re1 = "([+-]?\\d*[\\.,]?\\d*)"; // Float value QString re2 = "([a-zA-Z]*)"; // SI unit - QRegExp regex(re1 + re2); - const QString text = conv_threshold_cb_->currentText(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QRegularExpression regex(re1 + re2); + if (!regex.match(text).hasMatch()) + return; // String doesn't match the regex + + QStringList tokens = regex.match(text).capturedTexts(); +#else + QRegExp regex(re1 + re2); if (!regex.exactMatch(text)) return; // String doesn't match the regex QStringList tokens = regex.capturedTexts(); +#endif // For now, we simply assume that the unit is volt without modifiers const double thr = tokens.at(1).toDouble(); @@ -1127,13 +1134,22 @@ void AnalogSignal::on_conv_threshold_changed(int index) QString re3 = "\\/"; // Forward slash, not captured QString re4 = "([+-]?\\d*[\\.,]?\\d*)"; // Float value QString re5 = "([a-zA-Z]*)"; // SI unit + const QString text = conv_threshold_cb_->currentText(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QRegularExpression regex(re1 + re2 + re3 + re4 + re5); + + if (!regex.match(text).hasMatch()) + return; // String doesn't match the regex + + QStringList tokens = regex.match(text).capturedTexts(); +#else QRegExp regex(re1 + re2 + re3 + re4 + re5); - const QString text = conv_threshold_cb_->currentText(); if (!regex.exactMatch(text)) return; // String doesn't match the regex QStringList tokens = regex.capturedTexts(); +#endif // For now, we simply assume that the unit is volt without modifiers const double low_thr = tokens.at(1).toDouble();