QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
editorwidgets
qgsdoublespinbox.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsdoublespinbox.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 QGSDOUBLESPINBOX_H
17
#define QGSDOUBLESPINBOX_H
18
19
#include "qgis_gui.h"
20
#include "
qgis_sip.h
"
21
22
#include <QDoubleSpinBox>
23
24
class
QgsSpinBoxLineEdit;
25
26
27
#ifdef SIP_RUN
28
//%ModuleHeaderCode
29
// fix to allow compilation with sip that for some reason
30
// doesn't add this include to the file where the code from
31
// ConvertToSubClassCode goes.
32
#include <
qgsdoublespinbox.h
>
33
//%End
34
#endif
35
36
45
class
GUI_EXPORT
QgsDoubleSpinBox
:
public
QDoubleSpinBox
46
{
47
#ifdef SIP_RUN
48
SIP_CONVERT_TO_SUBCLASS_CODE
49
if
( qobject_cast<QgsDoubleSpinBox *>( sipCpp ) )
50
sipType = sipType_QgsDoubleSpinBox;
51
else
52
sipType = NULL;
53
SIP_END
54
#endif
55
56
Q_OBJECT
57
Q_PROPERTY(
bool
showClearButton
READ
showClearButton
WRITE
setShowClearButton
)
58
Q_PROPERTY(
bool
clearValue
READ
clearValue
WRITE
setClearValue
)
59
Q_PROPERTY(
bool
expressionsEnabled
READ
expressionsEnabled
WRITE
setExpressionsEnabled
)
60
61
public:
63
enum
ClearValueMode
64
{
65
MinimumValue
,
66
MaximumValue
,
67
CustomValue
,
68
};
69
74
explicit
QgsDoubleSpinBox
( QWidget *parent
SIP_TRANSFERTHIS
=
nullptr
);
75
82
void
setShowClearButton(
bool
showClearButton );
83
88
bool
showClearButton
()
const
{
return
mShowClearButton; }
89
95
void
setExpressionsEnabled(
bool
enabled );
96
102
bool
expressionsEnabled
()
const
{
return
mExpressionsEnabled; }
103
105
void
clear()
override
;
106
113
void
setClearValue(
double
customValue,
const
QString &clearValueText = QString() );
114
120
void
setClearValueMode( ClearValueMode mode,
const
QString &clearValueText = QString() );
121
126
double
clearValue()
const
;
127
135
bool
isCleared()
const
;
136
141
void
setLineEditAlignment( Qt::Alignment alignment );
142
148
void
setSpecialValueText(
const
QString &txt );
149
150
double
valueFromText(
const
QString &text )
const override
;
151
QValidator::State validate( QString &input,
int
&pos )
const override
;
152
void
paintEvent( QPaintEvent *e )
override
;
153
void
stepBy(
int
steps )
override
;
154
163
int
editingTimeoutInterval()
const
;
164
165
public
slots:
166
176
void
setEditingTimeoutInterval(
int
timeout );
177
178
signals:
179
184
void
returnPressed
();
185
190
void
textEdited
(
const
QString &text );
191
205
void
editingTimeout
(
double
value );
206
207
protected
:
208
void
changeEvent
( QEvent *event )
override
;
209
void
wheelEvent
( QWheelEvent *event )
override
;
210
void
focusOutEvent
( QFocusEvent *event )
override
;
211
// This is required because private implementation of
212
// QAbstractSpinBoxPrivate may trigger a second
213
// undesired event from the auto-repeat mouse timer
214
void
timerEvent
( QTimerEvent *event )
override
;
215
216
private
slots:
217
void
changed(
double
value );
218
void
onLastEditTimeout();
219
220
private
:
221
int
frameWidth()
const
;
222
bool
shouldShowClearForValue(
double
value )
const
;
223
224
QgsSpinBoxLineEdit *mLineEdit =
nullptr
;
225
226
bool
mShowClearButton =
true
;
227
ClearValueMode
mClearValueMode =
MinimumValue
;
228
double
mCustomClearValue = 0.0;
229
230
bool
mExpressionsEnabled =
true
;
231
232
QTimer *mLastEditTimer =
nullptr
;
233
double
mLastEditTimeoutValue = std::numeric_limits<double>::quiet_NaN();
234
235
QString stripped(
const
QString &originalText )
const
;
236
237
friend
class
TestQgsRangeWidgetWrapper
;
238
};
239
240
#endif
// QGSDOUBLESPINBOX_H
QgsDoubleSpinBox
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
Definition
qgsdoublespinbox.h:46
QgsDoubleSpinBox::clearValue
bool clearValue
Definition
qgsdoublespinbox.h:58
QgsDoubleSpinBox::showClearButton
bool showClearButton
Definition
qgsdoublespinbox.h:57
QgsDoubleSpinBox::wheelEvent
void wheelEvent(QWheelEvent *event) override
Definition
qgsdoublespinbox.cpp:87
QgsDoubleSpinBox::expressionsEnabled
bool expressionsEnabled
Definition
qgsdoublespinbox.h:59
QgsDoubleSpinBox::textEdited
void textEdited(const QString &text)
Emitted when the the value has been manually edited via line edit.
QgsDoubleSpinBox::editingTimeout
void editingTimeout(double value)
Emitted when either:
QgsDoubleSpinBox::showClearButton
bool showClearButton() const
Returns whether the widget is showing a clear button.
Definition
qgsdoublespinbox.h:88
QgsDoubleSpinBox::focusOutEvent
void focusOutEvent(QFocusEvent *event) override
Definition
qgsdoublespinbox.cpp:109
QgsDoubleSpinBox::changeEvent
void changeEvent(QEvent *event) override
Definition
qgsdoublespinbox.cpp:75
QgsDoubleSpinBox::ClearValueMode
ClearValueMode
Behavior when widget is cleared.
Definition
qgsdoublespinbox.h:64
QgsDoubleSpinBox::MaximumValue
@ MaximumValue
Reset value to maximum().
Definition
qgsdoublespinbox.h:66
QgsDoubleSpinBox::CustomValue
@ CustomValue
Reset value to custom value (see setClearValue() ).
Definition
qgsdoublespinbox.h:67
QgsDoubleSpinBox::MinimumValue
@ MinimumValue
Reset value to minimum().
Definition
qgsdoublespinbox.h:65
QgsDoubleSpinBox::TestQgsRangeWidgetWrapper
friend class TestQgsRangeWidgetWrapper
Definition
qgsdoublespinbox.h:237
QgsDoubleSpinBox::QgsDoubleSpinBox
QgsDoubleSpinBox(QWidget *parent=nullptr)
Constructor for QgsDoubleSpinBox.
Definition
qgsdoublespinbox.cpp:43
QgsDoubleSpinBox::setExpressionsEnabled
void setExpressionsEnabled(bool enabled)
Sets if the widget will allow entry of simple expressions, which are evaluated and then discarded.
Definition
qgsdoublespinbox.cpp:70
QgsDoubleSpinBox::setClearValue
void setClearValue(double customValue, const QString &clearValueText=QString())
Defines the clear value as a custom value and will automatically set the clear value mode to CustomVa...
Definition
qgsdoublespinbox.cpp:180
QgsDoubleSpinBox::setShowClearButton
void setShowClearButton(bool showClearButton)
Sets whether the widget will show a clear button.
Definition
qgsdoublespinbox.cpp:64
QgsDoubleSpinBox::timerEvent
void timerEvent(QTimerEvent *event) override
Definition
qgsdoublespinbox.cpp:115
QgsDoubleSpinBox::returnPressed
void returnPressed()
Emitted when the Return or Enter key is used in the line edit.
QgsDoubleSpinBox::expressionsEnabled
bool expressionsEnabled() const
Returns whether the widget will allow entry of simple expressions, which are evaluated and then disca...
Definition
qgsdoublespinbox.h:102
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
qgsdoublespinbox.h
Generated on
for QGIS API Documentation by
1.17.0