QGIS API Documentation 3.41.0-Master (57ec4277f5e)
Loading...
Searching...
No Matches
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | Friends | List of all members
QgsSpinBox Class Reference

The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value. More...

#include <qgsspinbox.h>

Inheritance diagram for QgsSpinBox:
Inheritance graph
[legend]

Public Types

enum  ClearValueMode { MinimumValue , MaximumValue , CustomValue }
 Behavior when widget is cleared. More...
 

Public Slots

void setEditingTimeoutInterval (int timeout)
 Sets the timeout (in milliseconds) threshold for the editingTimeout() signal to be emitted after an edit.
 

Signals

void editingTimeout (int value)
 Emitted when either:
 
void returnPressed ()
 Emitted when the Return or Enter key is used in the line edit.
 
void textEdited (const QString &text)
 Emitted when the the value has been manually edited via line edit.
 

Public Member Functions

 QgsSpinBox (QWidget *parent=nullptr)
 Constructor for QgsSpinBox.
 
void clear () override
 Sets the current value to the value defined by the clear value.
 
int clearValue () const
 Returns the value used when clear() is called.
 
int editingTimeoutInterval () const
 Returns the timeout (in milliseconds) threshold for the editingTimeout() signal to be emitted after an edit.
 
bool expressionsEnabled () const
 Returns whether the widget will allow entry of simple expressions, which are evaluated and then discarded.
 
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 CustomValue.
 
void setClearValueMode (ClearValueMode mode, const QString &clearValueText=QString())
 Defines if the clear value should be the minimum or maximum values of the widget or a custom value.
 
void setExpressionsEnabled (bool enabled)
 Sets if the widget will allow entry of simple expressions, which are evaluated and then discarded.
 
void setLineEditAlignment (Qt::Alignment alignment)
 Set alignment in the embedded line edit widget.
 
void setShowClearButton (bool showClearButton)
 Sets whether the widget will show a clear button.
 
void setSpecialValueText (const QString &txt)
 Set the special-value text to be txt If set, the spin box will display this text instead of a numeric value whenever the current value is equal to minimum().
 
bool showClearButton () const
 Returns whether the widget is showing a clear button.
 
void stepBy (int steps) override
 
QValidator::State validate (QString &input, int &pos) const override
 
int valueFromText (const QString &text) const override
 

Protected Member Functions

void changeEvent (QEvent *event) override
 
void focusOutEvent (QFocusEvent *event) override
 
void paintEvent (QPaintEvent *event) override
 
void timerEvent (QTimerEvent *event) override
 
void wheelEvent (QWheelEvent *event) override
 

Properties

bool clearValue
 
bool expressionsEnabled
 
bool showClearButton
 

Friends

class TestQgsRangeWidgetWrapper
 

Detailed Description

The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.

The clear value can be either the minimum or the maiximum value of the spin box or a custom value. This value can then be handled by a special value text.

Definition at line 42 of file qgsspinbox.h.

Member Enumeration Documentation

◆ ClearValueMode

Behavior when widget is cleared.

Enumerator
MinimumValue 

Reset value to minimum()

MaximumValue 

Reset value to maximum()

CustomValue 

Reset value to custom value (see setClearValue() )

Definition at line 60 of file qgsspinbox.h.

Constructor & Destructor Documentation

◆ QgsSpinBox()

QgsSpinBox::QgsSpinBox ( QWidget *  parent = nullptr)
explicit

Constructor for QgsSpinBox.

Parameters
parentparent widget

Definition at line 40 of file qgsspinbox.cpp.

Member Function Documentation

◆ changeEvent()

void QgsSpinBox::changeEvent ( QEvent *  event)
overrideprotected

Definition at line 71 of file qgsspinbox.cpp.

◆ clear()

void QgsSpinBox::clear ( )
override

Sets the current value to the value defined by the clear value.

Definition at line 145 of file qgsspinbox.cpp.

◆ clearValue()

int QgsSpinBox::clearValue ( ) const

Returns the value used when clear() is called.

See also
setClearValue()

Definition at line 190 of file qgsspinbox.cpp.

◆ editingTimeout

void QgsSpinBox::editingTimeout ( int  value)
signal

Emitted when either:

  1. 2 seconds has elapsed since the last value change in the widget (eg last key press or scroll wheel event)
  2. or, immediately after the widget has lost focus after its value was changed.

This signal can be used to respond semi-instantly to changes in the spin box, without responding too quickly while the user in the middle of setting the value.

See also
editingTimeoutInterval()
Since
QGIS 3.42

◆ editingTimeoutInterval()

int QgsSpinBox::editingTimeoutInterval ( ) const

Returns the timeout (in milliseconds) threshold for the editingTimeout() signal to be emitted after an edit.

See also
setEditingTimeoutInterval()
Since
QGIS 3.42

Definition at line 260 of file qgsspinbox.cpp.

◆ expressionsEnabled()

bool QgsSpinBox::expressionsEnabled ( ) const
inline

Returns whether the widget will allow entry of simple expressions, which are evaluated and then discarded.

Returns
true if spin box allows expression entry

Definition at line 99 of file qgsspinbox.h.

◆ focusOutEvent()

void QgsSpinBox::focusOutEvent ( QFocusEvent *  event)
overrideprotected

Definition at line 121 of file qgsspinbox.cpp.

◆ paintEvent()

void QgsSpinBox::paintEvent ( QPaintEvent *  event)
overrideprotected

Definition at line 83 of file qgsspinbox.cpp.

◆ returnPressed

void QgsSpinBox::returnPressed ( )
signal

Emitted when the Return or Enter key is used in the line edit.

Since
QGIS 3.40

◆ setClearValue()

void QgsSpinBox::setClearValue ( int  customValue,
const QString &  clearValueText = QString() 
)

Defines the clear value as a custom value and will automatically set the clear value mode to CustomValue.

Parameters
customValuedefines the numerical value used as the clear value
clearValueTextis the text displayed when the spin box is at the clear value. If not specified, no special value text is used.
See also
setClearValue()

Definition at line 152 of file qgsspinbox.cpp.

◆ setClearValueMode()

void QgsSpinBox::setClearValueMode ( QgsSpinBox::ClearValueMode  mode,
const QString &  clearValueText = QString() 
)

Defines if the clear value should be the minimum or maximum values of the widget or a custom value.

Parameters
modemode to user for clear value
clearValueTextis the text displayed when the spin box is at the clear value. If not specified, no special value text is used.

Definition at line 171 of file qgsspinbox.cpp.

◆ setEditingTimeoutInterval

void QgsSpinBox::setEditingTimeoutInterval ( int  timeout)
slot

Sets the timeout (in milliseconds) threshold for the editingTimeout() signal to be emitted after an edit.

See also
editingTimeoutInterval()
editingTimeout()
Since
QGIS 3.42

Definition at line 265 of file qgsspinbox.cpp.

◆ setExpressionsEnabled()

void QgsSpinBox::setExpressionsEnabled ( bool  enabled)

Sets if the widget will allow entry of simple expressions, which are evaluated and then discarded.

Parameters
enabledset to true to allow expression entry

Definition at line 66 of file qgsspinbox.cpp.

◆ setLineEditAlignment()

void QgsSpinBox::setLineEditAlignment ( Qt::Alignment  alignment)

Set alignment in the embedded line edit widget.

Parameters
alignment

Definition at line 200 of file qgsspinbox.cpp.

◆ setShowClearButton()

void QgsSpinBox::setShowClearButton ( bool  showClearButton)

Sets whether the widget will show a clear button.

The clear button allows users to reset the widget to a default or empty state.

Parameters
showClearButtonset to true to show the clear button, or false to hide it
See also
showClearButton()

Definition at line 60 of file qgsspinbox.cpp.

◆ setSpecialValueText()

void QgsSpinBox::setSpecialValueText ( const QString &  txt)

Set the special-value text to be txt If set, the spin box will display this text instead of a numeric value whenever the current value is equal to minimum().

Typical use is to indicate that this choice has a special (default) meaning.

Definition at line 205 of file qgsspinbox.cpp.

◆ showClearButton()

bool QgsSpinBox::showClearButton ( ) const
inline

Returns whether the widget is showing a clear button.

See also
setShowClearButton()

Definition at line 85 of file qgsspinbox.h.

◆ stepBy()

void QgsSpinBox::stepBy ( int  steps)
override

Definition at line 246 of file qgsspinbox.cpp.

◆ textEdited

void QgsSpinBox::textEdited ( const QString &  text)
signal

Emitted when the the value has been manually edited via line edit.

Since
QGIS 3.40

◆ timerEvent()

void QgsSpinBox::timerEvent ( QTimerEvent *  event)
overrideprotected

Definition at line 110 of file qgsspinbox.cpp.

◆ validate()

QValidator::State QgsSpinBox::validate ( QString &  input,
int &  pos 
) const
override

Definition at line 235 of file qgsspinbox.cpp.

◆ valueFromText()

int QgsSpinBox::valueFromText ( const QString &  text) const
override

Definition at line 219 of file qgsspinbox.cpp.

◆ wheelEvent()

void QgsSpinBox::wheelEvent ( QWheelEvent *  event)
overrideprotected

Definition at line 89 of file qgsspinbox.cpp.

Friends And Related Symbol Documentation

◆ TestQgsRangeWidgetWrapper

friend class TestQgsRangeWidgetWrapper
friend

Definition at line 226 of file qgsspinbox.h.

Property Documentation

◆ clearValue

bool QgsSpinBox::clearValue
readwrite

Definition at line 55 of file qgsspinbox.h.

◆ expressionsEnabled

bool QgsSpinBox::expressionsEnabled
readwrite

Definition at line 56 of file qgsspinbox.h.

◆ showClearButton

bool QgsSpinBox::showClearButton
readwrite

Definition at line 54 of file qgsspinbox.h.


The documentation for this class was generated from the following files: