diff options
author | Samuel Gaist <samuel.gaist@edeltech.ch> | 2017-01-21 01:00:40 +0100 |
---|---|---|
committer | Samuel Gaist <samuel.gaist@edeltech.ch> | 2017-02-15 14:45:51 +0000 |
commit | 6864374f05c7493be2c18079e3777483d480ac6e (patch) | |
tree | ee6f60d2bfbffacc1368f74829cbdef3ffdc584a /examples | |
parent | beb98bdafc7d935268d4e98888ba0ba3c85cf92d (diff) |
Example: migrate grabber to use QRegularExpression
Update the legacy grabber example to use the new QRegularExpression
class in place of the deprecated QRegExp.
Change-Id: I1d1871b7e82cdb214fdd8ad55a606d5e7682fab1
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/opengl/legacy/grabber/mainwindow.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/opengl/legacy/grabber/mainwindow.cpp b/examples/opengl/legacy/grabber/mainwindow.cpp index da022adcdf..6ea6a28051 100644 --- a/examples/opengl/legacy/grabber/mainwindow.cpp +++ b/examples/opengl/legacy/grabber/mainwindow.cpp @@ -203,10 +203,11 @@ QSize MainWindow::getSize() if (!ok) return QSize(); - QRegExp regExp(tr("([0-9]+) *x *([0-9]+)")); - if (regExp.exactMatch(text)) { - int width = regExp.cap(1).toInt(); - int height = regExp.cap(2).toInt(); + QRegularExpression regExp(tr("^([0-9]+) *x *([0-9]+)$")); + QRegularExpressionMatch match = regExp.match(text); + if (match.hasMatch()) { + int width = match.captured(1).toInt(); + int height = match.captured(2).toInt(); if (width > 0 && width < 2048 && height > 0 && height < 2048) return QSize(width, height); } |