Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_gui_widgets_qspinbox.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4//! [0]
5sb->setPrefix("$");
6//! [0]
7
8
9//! [1]
10sb->setSuffix(" km");
11//! [1]
12
13
14//! [2]
16//! [2]
17
18
19//! [3]
22//! [3]
23
24
25//! [4]
26spinbox->setPrefix("$");
27//! [4]
28
29
30//! [5]
31spinbox->setSuffix(" km");
32//! [5]
33
34
35//! [6]
36setRange(minimum, maximum);
37//! [6]
38
39
40//! [7]
43//! [7]
44
45//! [8]
46int IconSizeSpinBox::valueFromText(const QString &text) const
47{
48 static const QRegularExpression regExp(tr("(\\d+)(\\s*[xx]\\s*\\d+)?"));
49 Q_ASSERT(regExp.isValid());
50
51 const QRegularExpressionMatch match = regExp.match(text);
52 if (match.isValid())
53 return match.captured(1).toInt();
54 return 0;
55}
56//! [8]
57
58//! [9]
59QString IconSizeSpinBox::textFromValue(int value) const
60{
61 return tr("%1 x %1").arg(value);
62}
63//! [9]
setMaximum(maximum)
setMinimum(minimum)
[2]
setRange(minimum, maximum)
[1]