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 <szehowe.koh@gmail.com>
This commit is contained in:
Samuel Gaist 2017-01-21 23:33:14 +01:00
parent 280225495d
commit a1cf6e5281

View File

@ -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));