diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-06-26 14:28:44 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2023-06-28 09:56:40 +0200 |
commit | c3fd8e911ea361df7f1e6fe971f8835d2093db7c (patch) | |
tree | b9d46d533872f4222953491fc93a0c0805d70b52 /tests/manual/examples/widgets/widgets/icons/iconsizespinbox.cpp | |
parent | 95595d68bee7ef9e58100e4230f71d7f065eacb7 (diff) |
Move icons example to manual test
Pick-to: 6.5 6.6
Change-Id: I08f44448f96a61f780c21d628954879c7b28dce3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/manual/examples/widgets/widgets/icons/iconsizespinbox.cpp')
-rw-r--r-- | tests/manual/examples/widgets/widgets/icons/iconsizespinbox.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/manual/examples/widgets/widgets/icons/iconsizespinbox.cpp b/tests/manual/examples/widgets/widgets/icons/iconsizespinbox.cpp new file mode 100644 index 0000000000..16c88f4dd0 --- /dev/null +++ b/tests/manual/examples/widgets/widgets/icons/iconsizespinbox.cpp @@ -0,0 +1,33 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#include "iconsizespinbox.h" + +#include <QRegularExpression> + +//! [0] +IconSizeSpinBox::IconSizeSpinBox(QWidget *parent) + : QSpinBox(parent) +{ +} +//! [0] + +//! [1] +int IconSizeSpinBox::valueFromText(const QString &text) const +{ + static const QRegularExpression regExp(tr("(\\d+)(\\s*[xx]\\s*\\d+)?")); + Q_ASSERT(regExp.isValid()); + + const QRegularExpressionMatch match = regExp.match(text); + if (match.isValid()) + return match.captured(1).toInt(); + return 0; +} +//! [1] + +//! [2] +QString IconSizeSpinBox::textFromValue(int value) const +{ + return tr("%1 x %1").arg(value); +} +//! [2] |