X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fwidgets%2Ftimestampspinbox.cpp;h=b99a640a843055fa2d2271bcae9c67d6607f63a9;hb=292b6ebc37281a28982e5d9e43471d9b3eab1d8f;hp=01424a5b7837654e50c36de5f3f4ce27c33ec8a1;hpb=ae726b70a7ada9a4be5808e00f0c951318479684;p=pulseview.git diff --git a/pv/widgets/timestampspinbox.cpp b/pv/widgets/timestampspinbox.cpp index 01424a5b..b99a640a 100644 --- a/pv/widgets/timestampspinbox.cpp +++ b/pv/widgets/timestampspinbox.cpp @@ -20,7 +20,11 @@ #include "timestampspinbox.hpp" #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#else #include +#endif namespace pv { namespace widgets { @@ -93,10 +97,25 @@ void TimestampSpinBox::setValue(const pv::util::Timestamp& val) void TimestampSpinBox::on_editingFinished() { - QRegExp re(R"(\s*([-+]?)\s*([0-9]+\.?[0-9]*).*)"); + static const auto re_pattern = R"(\s*([-+]?)\s*([0-9]+\.?[0-9]*).*)"; + + bool has_match; + QStringList captures; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QRegularExpression re(re_pattern); + has_match = re.match(text()).hasMatch(); + if (has_match) { + captures = re.match(text()).capturedTexts(); + } +#else + QRegExp re(re_pattern); + has_match = re.exactMatch(text()); + if (has_match) { + captures = re.capturedTexts(); + } +#endif - if (re.exactMatch(text())) { - QStringList captures = re.capturedTexts(); + if (has_match) { captures.removeFirst(); // remove entire match QString str = captures.join(""); setValue(pv::util::Timestamp(str.toStdString()));