Qt 4.8
qlcdnumber.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QLCDNUMBER_H
43 #define QLCDNUMBER_H
44 
45 #include <QtGui/qframe.h>
46 #include <QtCore/qbitarray.h>
47 
49 
51 
52 QT_MODULE(Gui)
53 
54 #ifndef QT_NO_LCDNUMBER
55 
56 class QLCDNumberPrivate;
57 class Q_GUI_EXPORT QLCDNumber : public QFrame // LCD number widget
58 {
59  Q_OBJECT
61  bool smallDecimalPoint;
62  int numDigits;
63  int digitCount;
64  Mode mode;
65  SegmentStyle segmentStyle;
66  double value;
67  int intValue;
68 
69 public:
70  explicit QLCDNumber(QWidget* parent = 0);
71  explicit QLCDNumber(uint numDigits, QWidget* parent = 0);
72  ~QLCDNumber();
73 
74  enum Mode {
75  Hex, Dec, Oct, Bin
76 #if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
77  , HEX = Hex, DEC = Dec, OCT = Oct, BIN = Bin
78 #endif
79  };
80  enum SegmentStyle {
81  Outline, Filled, Flat
82  };
83 
84  bool smallDecimalPoint() const;
85 #ifdef QT_DEPRECATED
86  QT_DEPRECATED int numDigits() const;
87  QT_DEPRECATED void setNumDigits(int nDigits);
88 #endif
89  int digitCount() const;
90  void setDigitCount(int nDigits);
91 
92  bool checkOverflow(double num) const;
93  bool checkOverflow(int num) const;
94 
95  Mode mode() const;
96  void setMode(Mode);
97 
98  SegmentStyle segmentStyle() const;
99  void setSegmentStyle(SegmentStyle);
100 
101  double value() const;
102  int intValue() const;
103 
104  QSize sizeHint() const;
105 
106 public Q_SLOTS:
107  void display(const QString &str);
108  void display(int num);
109  void display(double num);
110  void setHexMode();
111  void setDecMode();
112  void setOctMode();
113  void setBinMode();
114  void setSmallDecimalPoint(bool);
115 
116 Q_SIGNALS:
117  void overflow();
118 
119 protected:
120  bool event(QEvent *e);
121  void paintEvent(QPaintEvent *);
122 
123 public:
124 #ifdef QT3_SUPPORT
125  QT3_SUPPORT_CONSTRUCTOR QLCDNumber(QWidget* parent, const char* name);
126  QT3_SUPPORT_CONSTRUCTOR QLCDNumber(uint numDigits, QWidget* parent, const char* name);
127 
128  QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
129  QT3_SUPPORT int margin() const
130  { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
131 #endif
132 
133 private:
136 };
137 
138 #endif // QT_NO_LCDNUMBER
139 
141 
143 
144 #endif // QLCDNUMBER_H
void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
Definition: qframe.cpp:527
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
Mode
This type determines how numbers are shown.
Definition: qlcdnumber.h:74
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
void getContentsMargins(int *left, int *top, int *right, int *bottom) const
Returns the widget&#39;s contents margins for left, top, right, and bottom.
Definition: qwidget.cpp:7509
void setContentsMargins(int left, int top, int right, int bottom)
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom.
Definition: qwidget.cpp:7449
static int numDigits(qlonglong n)
Definition: qvalidator.cpp:385
const char * name
unsigned int uint
Definition: qglobal.h:996
#define Q_OBJECT
Definition: qobjectdefs.h:157
bool event(QEvent *e)
Reimplemented Function
Definition: qframe.cpp:587
The QLCDNumber widget displays a number with LCD-like digits.
Definition: qlcdnumber.h:57
SegmentStyle
This type determines the visual appearance of the QLCDNumber widget.
Definition: qlcdnumber.h:80
#define QT_DEPRECATED
Definition: qglobal.h:1094
QSize sizeHint() const
em>Reimplemented Function
Definition: qframe.cpp:508
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
The QFrame class is the base class of widgets that can have a frame.
Definition: qframe.h:55
#define QT_END_HEADER
Definition: qglobal.h:137