QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
editorwidgets
qgsspinbox.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsspinbox.h
3
--------------------------------------
4
Date : 09.2014
5
Copyright : (C) 2014 Denis Rouzaud
6
Email : denis.rouzaud@gmail.com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef QGSSPINBOX_H
17
#define QGSSPINBOX_H
18
19
#include "qgis_gui.h"
20
#include "
qgis_sip.h
"
21
22
#include <QSpinBox>
23
24
class
QgsSpinBoxLineEdit;
25
26
27
#ifdef SIP_RUN
28
//%ModuleHeaderCode
29
// fix to allow compilation with sip 4.7 that for some reason
30
// doesn't add this include to the file where the code from
31
// ConvertToSubClassCode goes.
32
#include <
qgsspinbox.h
>
33
//%End
34
#endif
35
36
44
class
GUI_EXPORT
QgsSpinBox
:
public
QSpinBox
45
{
46
#ifdef SIP_RUN
47
SIP_CONVERT_TO_SUBCLASS_CODE
48
if
( qobject_cast<QgsSpinBox *>( sipCpp ) )
49
sipType = sipType_QgsSpinBox;
50
else
51
sipType = NULL;
52
SIP_END
53
#endif
54
55
Q_OBJECT
56
Q_PROPERTY(
bool
showClearButton
READ
showClearButton
WRITE
setShowClearButton
)
57
Q_PROPERTY(
bool
clearValue
READ
clearValue
WRITE
setClearValue
)
58
Q_PROPERTY(
bool
expressionsEnabled
READ
expressionsEnabled
WRITE
setExpressionsEnabled
)
59
60
public:
62
enum
ClearValueMode
63
{
64
MinimumValue
,
65
MaximumValue
,
66
CustomValue
,
67
};
68
73
explicit
QgsSpinBox
( QWidget *parent
SIP_TRANSFERTHIS
=
nullptr
);
74
81
void
setShowClearButton(
bool
showClearButton );
82
87
bool
showClearButton
()
const
{
return
mShowClearButton; }
88
94
void
setExpressionsEnabled(
bool
enabled );
95
101
bool
expressionsEnabled
()
const
{
return
mExpressionsEnabled; }
102
104
void
clear()
override
;
105
112
void
setClearValue(
int
customValue,
const
QString &clearValueText = QString() );
113
119
void
setClearValueMode( ClearValueMode mode,
const
QString &clearValueText = QString() );
120
125
int
clearValue()
const
;
126
131
void
setLineEditAlignment( Qt::Alignment alignment );
132
138
void
setSpecialValueText(
const
QString &txt );
139
140
int
valueFromText(
const
QString &text )
const override
;
141
QValidator::State validate( QString &input,
int
&pos )
const override
;
142
void
stepBy(
int
steps )
override
;
143
152
int
editingTimeoutInterval()
const
;
153
154
public
slots:
155
165
void
setEditingTimeoutInterval(
int
timeout );
166
167
signals:
168
173
void
returnPressed
();
174
179
void
textEdited
(
const
QString &text );
180
194
void
editingTimeout
(
int
value );
195
196
protected
:
197
void
changeEvent
( QEvent *event )
override
;
198
void
paintEvent
( QPaintEvent *event )
override
;
199
void
wheelEvent
( QWheelEvent *event )
override
;
200
// This is required because private implementation of
201
// QAbstractSpinBoxPrivate may trigger a second
202
// undesired event from the auto-repeat mouse timer
203
void
timerEvent
( QTimerEvent *event )
override
;
204
void
focusOutEvent
( QFocusEvent *event )
override
;
205
206
private
slots:
207
void
changed(
int
value );
208
void
onLastEditTimeout();
209
210
private
:
211
int
frameWidth()
const
;
212
bool
shouldShowClearForValue(
int
value )
const
;
213
214
QgsSpinBoxLineEdit *mLineEdit =
nullptr
;
215
216
bool
mShowClearButton =
true
;
217
ClearValueMode
mClearValueMode =
MinimumValue
;
218
int
mCustomClearValue = 0;
219
220
bool
mExpressionsEnabled =
true
;
221
222
QTimer *mLastEditTimer =
nullptr
;
223
bool
mHasEmittedEditTimeout =
false
;
224
int
mLastEditTimeoutValue = 0;
225
226
QString stripped(
const
QString &originalText )
const
;
227
228
friend
class
TestQgsRangeWidgetWrapper
;
229
};
230
231
#endif
// QGSSPINBOX_H
QgsSpinBox
A spin box with a clear button that will set the value to the defined clear value.
Definition
qgsspinbox.h:45
QgsSpinBox::returnPressed
void returnPressed()
Emitted when the Return or Enter key is used in the line edit.
QgsSpinBox::ClearValueMode
ClearValueMode
Behavior when widget is cleared.
Definition
qgsspinbox.h:63
QgsSpinBox::MaximumValue
@ MaximumValue
Reset value to maximum().
Definition
qgsspinbox.h:65
QgsSpinBox::MinimumValue
@ MinimumValue
Reset value to minimum().
Definition
qgsspinbox.h:64
QgsSpinBox::CustomValue
@ CustomValue
Reset value to custom value (see setClearValue() ).
Definition
qgsspinbox.h:66
QgsSpinBox::showClearButton
bool showClearButton() const
Returns whether the widget is showing a clear button.
Definition
qgsspinbox.h:87
QgsSpinBox::showClearButton
bool showClearButton
Definition
qgsspinbox.h:56
QgsSpinBox::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition
qgsspinbox.cpp:91
QgsSpinBox::editingTimeout
void editingTimeout(int value)
Emitted when either:
QgsSpinBox::setShowClearButton
void setShowClearButton(bool showClearButton)
Sets whether the widget will show a clear button.
Definition
qgsspinbox.cpp:62
QgsSpinBox::focusOutEvent
void focusOutEvent(QFocusEvent *event) override
Definition
qgsspinbox.cpp:123
QgsSpinBox::QgsSpinBox
QgsSpinBox(QWidget *parent=nullptr)
Constructor for QgsSpinBox.
Definition
qgsspinbox.cpp:42
QgsSpinBox::expressionsEnabled
bool expressionsEnabled() const
Returns whether the widget will allow entry of simple expressions, which are evaluated and then disca...
Definition
qgsspinbox.h:101
QgsSpinBox::textEdited
void textEdited(const QString &text)
Emitted when the the value has been manually edited via line edit.
QgsSpinBox::paintEvent
void paintEvent(QPaintEvent *event) override
Definition
qgsspinbox.cpp:85
QgsSpinBox::clearValue
bool clearValue
Definition
qgsspinbox.h:57
QgsSpinBox::TestQgsRangeWidgetWrapper
friend class TestQgsRangeWidgetWrapper
Definition
qgsspinbox.h:228
QgsSpinBox::expressionsEnabled
bool expressionsEnabled
Definition
qgsspinbox.h:58
QgsSpinBox::timerEvent
void timerEvent(QTimerEvent *event) override
Definition
qgsspinbox.cpp:112
QgsSpinBox::setClearValue
void setClearValue(int customValue, const QString &clearValueText=QString())
Defines the clear value as a custom value and will automatically set the clear value mode to CustomVa...
Definition
qgsspinbox.cpp:154
QgsSpinBox::setExpressionsEnabled
void setExpressionsEnabled(bool enabled)
Sets if the widget will allow entry of simple expressions, which are evaluated and then discarded.
Definition
qgsspinbox.cpp:68
QgsSpinBox::changeEvent
void changeEvent(QEvent *event) override
Definition
qgsspinbox.cpp:73
qgis_sip.h
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition
qgis_sip.h:203
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
SIP_END
#define SIP_END
Definition
qgis_sip.h:220
qgsspinbox.h
Generated on
for QGIS API Documentation by
1.17.0