1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QLCDNUMBER_H
5#define QLCDNUMBER_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qframe.h>
9
10QT_BEGIN_NAMESPACE
11
12QT_REQUIRE_CONFIG(lcdnumber);
13
14class QLCDNumberPrivate;
15class Q_WIDGETS_EXPORT QLCDNumber : public QFrame // LCD number widget
16{
17 Q_OBJECT
18 Q_PROPERTY(bool smallDecimalPoint READ smallDecimalPoint WRITE setSmallDecimalPoint)
19 Q_PROPERTY(int digitCount READ digitCount WRITE setDigitCount)
20 Q_PROPERTY(Mode mode READ mode WRITE setMode)
21 Q_PROPERTY(SegmentStyle segmentStyle READ segmentStyle WRITE setSegmentStyle)
22 Q_PROPERTY(double value READ value WRITE display)
23 Q_PROPERTY(int intValue READ intValue WRITE display)
24
25public:
26 explicit QLCDNumber(QWidget* parent = nullptr);
27 explicit QLCDNumber(uint numDigits, QWidget* parent = nullptr);
28 ~QLCDNumber();
29
30 enum Mode {
31 Hex, Dec, Oct, Bin
32 };
33 Q_ENUM(Mode)
34 enum SegmentStyle {
35 Outline, Filled, Flat
36 };
37 Q_ENUM(SegmentStyle)
38
39 bool smallDecimalPoint() const;
40 int digitCount() const;
41 void setDigitCount(int nDigits);
42
43 bool checkOverflow(double num) const;
44 bool checkOverflow(int num) const;
45
46 Mode mode() const;
47 void setMode(Mode);
48
49 SegmentStyle segmentStyle() const;
50 void setSegmentStyle(SegmentStyle);
51
52 double value() const;
53 int intValue() const;
54
55 QSize sizeHint() const override;
56
57public Q_SLOTS:
58 void display(const QString &str);
59 void display(int num);
60 void display(double num);
61 void setHexMode();
62 void setDecMode();
63 void setOctMode();
64 void setBinMode();
65 void setSmallDecimalPoint(bool);
66
67Q_SIGNALS:
68 void overflow();
69
70protected:
71 bool event(QEvent *e) override;
72 void paintEvent(QPaintEvent *) override;
73
74public:
75
76private:
77 Q_DISABLE_COPY(QLCDNumber)
78 Q_DECLARE_PRIVATE(QLCDNumber)
79};
80
81QT_END_NAMESPACE
82
83#endif // QLCDNUMBER_H
84

source code of qtbase/src/widgets/widgets/qlcdnumber.h