Qt 4.8
qabstractspinbox.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 QABSTRACTSPINBOX_H
43 #define QABSTRACTSPINBOX_H
44 
45 #include <QtGui/qwidget.h>
46 #include <QtGui/qvalidator.h>
47 
49 
51 
52 QT_MODULE(Gui)
53 
54 #ifndef QT_NO_SPINBOX
55 
56 class QLineEdit;
57 
60 
62 {
63  Q_OBJECT
64 
67  bool wrapping;
68  bool frame;
69  Qt::Alignment alignment;
70  bool readOnly;
71  ButtonSymbols buttonSymbols;
72  QString specialValueText;
74  bool accelerated;
75  CorrectionMode correctionMode;
76  bool acceptableInput;
77  bool keyboardTracking;
78 public:
79  explicit QAbstractSpinBox(QWidget *parent = 0);
81 
82  enum StepEnabledFlag { StepNone = 0x00, StepUpEnabled = 0x01,
83  StepDownEnabled = 0x02 };
84  Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)
85 
86  enum ButtonSymbols { UpDownArrows, PlusMinus, NoButtons };
87 
88  ButtonSymbols buttonSymbols() const;
89  void setButtonSymbols(ButtonSymbols bs);
90 
91  enum CorrectionMode { CorrectToPreviousValue, CorrectToNearestValue };
92 
93  void setCorrectionMode(CorrectionMode cm);
94  CorrectionMode correctionMode() const;
95 
96  bool hasAcceptableInput() const;
97  QString text() const;
98 
99  QString specialValueText() const;
100  void setSpecialValueText(const QString &txt);
101 
102  bool wrapping() const;
103  void setWrapping(bool w);
104 
105  void setReadOnly(bool r);
106  bool isReadOnly() const;
107 
108  void setKeyboardTracking(bool kt);
109  bool keyboardTracking() const;
110 
111  void setAlignment(Qt::Alignment flag);
112  Qt::Alignment alignment() const;
113 
114  void setFrame(bool);
115  bool hasFrame() const;
116 
117  void setAccelerated(bool on);
118  bool isAccelerated() const;
119 
120  QSize sizeHint() const;
121  QSize minimumSizeHint() const;
122  void interpretText();
123  bool event(QEvent *event);
124 
126 
127  virtual QValidator::State validate(QString &input, int &pos) const;
128  virtual void fixup(QString &input) const;
129 
130  virtual void stepBy(int steps);
131 public Q_SLOTS:
132  void stepUp();
133  void stepDown();
134  void selectAll();
135  virtual void clear();
136 protected:
137  void resizeEvent(QResizeEvent *event);
138  void keyPressEvent(QKeyEvent *event);
139  void keyReleaseEvent(QKeyEvent *event);
140 #ifndef QT_NO_WHEELEVENT
141  void wheelEvent(QWheelEvent *event);
142 #endif
143  void focusInEvent(QFocusEvent *event);
144  void focusOutEvent(QFocusEvent *event);
145  void contextMenuEvent(QContextMenuEvent *event);
146  void changeEvent(QEvent *event);
147  void closeEvent(QCloseEvent *event);
148  void hideEvent(QHideEvent *event);
149  void mousePressEvent(QMouseEvent *event);
150  void mouseReleaseEvent(QMouseEvent *event);
151  void mouseMoveEvent(QMouseEvent *event);
152  void timerEvent(QTimerEvent *event);
153  void paintEvent(QPaintEvent *event);
154  void showEvent(QShowEvent *event);
155  void initStyleOption(QStyleOptionSpinBox *option) const;
156 
157  QLineEdit *lineEdit() const;
158  void setLineEdit(QLineEdit *edit);
159 
160  virtual StepEnabled stepEnabled() const;
161 Q_SIGNALS:
162  void editingFinished();
163 protected:
165 
166 private:
167  Q_PRIVATE_SLOT(d_func(), void _q_editorTextChanged(const QString &))
168  Q_PRIVATE_SLOT(d_func(), void _q_editorCursorPositionChanged(int, int))
169 
172 };
173 Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSpinBox::StepEnabled)
174 
175 #endif // QT_NO_SPINBOX
176 
178 
180 
181 #endif // QABSTRACTSPINBOX_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QKeyEvent class describes a key event.
Definition: qevent.h:224
virtual void showEvent(QShowEvent *)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
Definition: qwidget.cpp:9842
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
#define QT_MODULE(x)
Definition: qglobal.h:2783
virtual QSize minimumSizeHint() const
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
virtual void mouseReleaseEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse release even...
Definition: qwidget.cpp:9286
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
virtual void mousePressEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition: qwidget.cpp:9261
virtual void timerEvent(QTimerEvent *)
This event handler can be reimplemented in a subclass to receive timer events for the object...
Definition: qobject.cpp:1294
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static void clear(QVariant::Private *d)
Definition: qvariant.cpp:197
virtual void resizeEvent(QResizeEvent *)
This event handler can be reimplemented in a subclass to receive widget resize events which are passe...
Definition: qwidget.cpp:9587
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
virtual void keyReleaseEvent(QKeyEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive key release events...
Definition: qwidget.cpp:9407
#define Q_SLOTS
Definition: qobjectdefs.h:71
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
This method is only relevant for input widgets.
Definition: qwidget.cpp:9683
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_SIGNALS
Definition: qobjectdefs.h:72
ButtonSymbols
This enum type describes the symbols that can be displayed on the buttons in a spin box...
virtual void focusOutEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) f...
Definition: qwidget.cpp:9457
virtual QSize sizeHint() const
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
virtual void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events passed in event...
Definition: qwidget.cpp:9548
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
CorrectionMode
This enum type describes the mode the spinbox will use to correct an QValidator::Intermediate value i...
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
The QStyleOptionSpinBox class is used to describe the parameters necessary for drawing a spin box...
Definition: qstyleoption.h:729
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qwidget.cpp:9170
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition: qevent.h:388
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
virtual void keyPressEvent(QKeyEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
Definition: qwidget.cpp:9375
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
virtual void contextMenuEvent(QContextMenuEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive widget context men...
Definition: qwidget.cpp:9645
InputMethodQuery
Definition: qnamespace.h:1541
virtual void wheelEvent(QWheelEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive wheel events for t...
Definition: qwidget.cpp:9326
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
virtual void hideEvent(QHideEvent *)
This event handler can be reimplemented in a subclass to receive widget hide events.
Definition: qwidget.cpp:9864
virtual void closeEvent(QCloseEvent *)
This event handler is called with the given event when Qt receives a window close request for a top-l...
Definition: qwidget.cpp:9626
State
This enum type defines the states in which a validated string can exist.
Definition: qvalidator.h:67
Definition: qnamespace.h:54
The QLineEdit widget is a one-line text editor.
Definition: qlineedit.h:66
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
bool event(QEvent *)
This is the main event handler; it handles event event.
Definition: qwidget.cpp:8636
virtual void mouseMoveEvent(QMouseEvent *)
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events ...
Definition: qwidget.cpp:9239
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
#define QT_END_HEADER
Definition: qglobal.h:137
virtual void focusInEvent(QFocusEvent *)
This event handler can be reimplemented in a subclass to receive keyboard focus events (focus receive...
Definition: qwidget.cpp:9431
The QCloseEvent class contains parameters that describe a close event.
Definition: qevent.h:364
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
#define text
Definition: qobjectdefs.h:80