blob: ec4b5bf27f195bd44f9a386185bc67a192e93797 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
sb->setPrefix("$");
//! [0]
//! [1]
sb->setSuffix(" km");
//! [1]
//! [2]
setRange(minimum, maximum);
//! [2]
//! [3]
setMinimum(minimum);
setMaximum(maximum);
//! [3]
//! [4]
spinbox->setPrefix("$");
//! [4]
//! [5]
spinbox->setSuffix(" km");
//! [5]
//! [6]
setRange(minimum, maximum);
//! [6]
//! [7]
setMinimum(minimum);
setMaximum(maximum);
//! [7]
//! [8]
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;
}
//! [8]
//! [9]
QString IconSizeSpinBox::textFromValue(int value) const
{
return tr("%1 x %1").arg(value);
}
//! [9]
|