QtGui/qabstractspinbox.h Source File

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 
58 class QAbstractSpinBoxPrivate;
60 
61 class Q_GUI_EXPORT QAbstractSpinBox : public QWidget
62 {
63  Q_OBJECT
64 
67  Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
68  Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
69  Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
70  Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
71  Q_PROPERTY(ButtonSymbols buttonSymbols READ buttonSymbols WRITE setButtonSymbols)
72  Q_PROPERTY(QString specialValueText READ specialValueText WRITE setSpecialValueText)
73  Q_PROPERTY(QString text READ text)
74  Q_PROPERTY(bool accelerated READ isAccelerated WRITE setAccelerated)
75  Q_PROPERTY(CorrectionMode correctionMode READ correctionMode WRITE setCorrectionMode)
76  Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
77  Q_PROPERTY(bool keyboardTracking READ keyboardTracking WRITE setKeyboardTracking)
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:
164  QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent = 0);
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 
170  Q_DECLARE_PRIVATE(QAbstractSpinBox)
171  Q_DISABLE_COPY(QAbstractSpinBox)
172 };
173 Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSpinBox::StepEnabled)
174 
175 #endif // QT_NO_SPINBOX
176 
178 
180 
181 #endif // QABSTRACTSPINBOX_H
GLdouble GLdouble GLdouble r
Definition: GLee.h:1189
GLenum GLenum GLenum input
Definition: GLee.h:5776
bool event(QEvent *)
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
virtual void contextMenuEvent(QContextMenuEvent *)
virtual void focusInEvent(QFocusEvent *)
virtual void wheelEvent(QWheelEvent *)
virtual void mouseMoveEvent(QMouseEvent *)
virtual void focusOutEvent(QFocusEvent *)
virtual void keyPressEvent(QKeyEvent *)
Definition: qnamespace.h:54
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
virtual void resizeEvent(QResizeEvent *)
virtual void closeEvent(QCloseEvent *)
#define Q_SLOTS
Definition: qobjectdefs.h:71
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
virtual void timerEvent(QTimerEvent *)
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
virtual void mouseReleaseEvent(QMouseEvent *)
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const
virtual void keyReleaseEvent(QKeyEvent *)
virtual QSize sizeHint() const
InputMethodQuery
Definition: qnamespace.h:1541
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual void showEvent(QShowEvent *)
Definition: qsize.h:53
virtual void paintEvent(QPaintEvent *)
virtual void hideEvent(QHideEvent *)
virtual void mousePressEvent(QMouseEvent *)
GLubyte GLubyte GLubyte GLubyte w
Definition: GLee.h:1775
virtual QSize minimumSizeHint() const
#define QT_END_HEADER
Definition: qglobal.h:142
virtual void changeEvent(QEvent *)