From a1cf6e52818d10ac5d4e6339d5bc4cf9b01bf44e Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 21 Jan 2017 23:33:14 +0100 Subject: Example: migrate stylesheet example to use QRegularExpression Update the stylesheet example to use the new QRegularExpression class in place of the deprecated QRegExp. Change-Id: I7061b8fd462ff012cb67bfdade656b3bfe442dd8 Reviewed-by: Sze Howe Koh --- examples/widgets/widgets/stylesheet/stylesheeteditor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp b/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp index 7a75233628..3247fa774d 100644 --- a/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp +++ b/examples/widgets/widgets/stylesheet/stylesheeteditor.cpp @@ -57,11 +57,12 @@ StyleSheetEditor::StyleSheetEditor(QWidget *parent) { ui.setupUi(this); - QRegExp regExp(".(.*)\\+?Style"); + QRegularExpression regExp("^.(.*)\\+?Style$"); QString defaultStyle = QApplication::style()->metaObject()->className(); + QRegularExpressionMatch match = regExp.match(defaultStyle); - if (regExp.exactMatch(defaultStyle)) - defaultStyle = regExp.cap(1); + if (match.hasMatch()) + defaultStyle = match.captured(1); ui.styleCombo->addItems(QStyleFactory::keys()); ui.styleCombo->setCurrentIndex(ui.styleCombo->findText(defaultStyle, Qt::MatchContains)); -- cgit v1.2.3