QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Signals | Public Member Functions | Protected Member Functions | List of all members
QgsDateEdit Class Reference

The QgsDateEdit class is a QDateEdit widget with the capability of setting/reading null dates. More...

#include <qgsdatetimeedit.h>

Inheritance diagram for QgsDateEdit:
Inheritance graph
[legend]

Signals

void dateValueChanged (const QDate &date)
 Signal emitted whenever the date changes.
 
- Signals inherited from QgsDateTimeEdit
void valueChanged (const QDateTime &date)
 Signal emitted whenever the value changes.
 

Public Member Functions

 QgsDateEdit (QWidget *parent=nullptr)
 Constructor for QgsDateEdit.
 
void setDate (const QDate &date)
 Sets the date for the widget and handles null dates.
 
- Public Member Functions inherited from QgsDateTimeEdit
 QgsDateTimeEdit (QWidget *parent=nullptr)
 Constructor for QgsDateTimeEdit.
 
bool allowNull () const
 If the widget allows setting null date/time.
 
void clear () override
 Set the current date as NULL.
 
QDate date () const
 Returns the date which can be a null date.
 
QDateTime dateTime () const
 Returns the date time which can be a null date/time.
 
bool event (QEvent *event) override
 Reimplemented to enable/disable the clear action depending on read-only status.
 
QString nullRepresentation () const
 Returns the widget's NULL representation, which defaults to QgsApplication::nullRepresentation().
 
void setAllowNull (bool allowNull)
 Determines if the widget allows setting null date/time.
 
void setDateTime (const QDateTime &dateTime)
 Set the date time in the widget and handles null date times.
 
void setEmpty ()
 Resets the widget to show no value (ie, an "unknown" state).
 
void setNullRepresentation (const QString &null)
 Sets the widget's null representation, which defaults to QgsApplication::nullRepresentation().
 
QTime time () const
 Returns the time which can be a null time.
 

Protected Member Functions

void emitValueChanged (const QVariant &value) override
 Emits the widget's correct value changed signal.
 
- Protected Member Functions inherited from QgsDateTimeEdit
void displayNull (bool updateCalendar=false)
 write the null value representation to the line edit without changing the value
 
void focusInEvent (QFocusEvent *event) override
 
void focusOutEvent (QFocusEvent *event) override
 
bool isNull () const
 Returns true if the widget is currently set to a null value.
 
void mousePressEvent (QMouseEvent *event) override
 
void showEvent (QShowEvent *event) override
 
void wheelEvent (QWheelEvent *event) override
 

Additional Inherited Members

- Protected Attributes inherited from QgsDateTimeEdit
int mBlockChangedSignal = 0
 Block change signals if true.
 
bool mIsEmpty = false
 true if the widget is empty
 
- Properties inherited from QgsDateTimeEdit
bool allowNull
 

Detailed Description

The QgsDateEdit class is a QDateEdit widget with the capability of setting/reading null dates.

Warning
You should use the signal dateValueChanged of this subclass rather than QDateTimeEdit::dateChanged. (If you consequently connect parent's dateChanged signal and call date() afterwards there is no guarantee that NULL values will be correctly handled).
See also
QgsDateTimeEdit
QgsTimeEdit
Since
QGIS 3.14

Definition at line 277 of file qgsdatetimeedit.h.

Constructor & Destructor Documentation

◆ QgsDateEdit()

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

Constructor for QgsDateEdit.

The current time is used by default. The widget is allowing null by default. If allow null is disabled, you should check allowNull before getting values from the widget.

Definition at line 441 of file qgsdatetimeedit.cpp.

Member Function Documentation

◆ dateValueChanged

void QgsDateEdit::dateValueChanged ( const QDate &  date)
signal

Signal emitted whenever the date changes.

◆ emitValueChanged()

void QgsDateEdit::emitValueChanged ( const QVariant &  value)
overrideprotectedvirtual

Emits the widget's correct value changed signal.

Reimplemented from QgsDateTimeEdit.

Definition at line 472 of file qgsdatetimeedit.cpp.

◆ setDate()

void QgsDateEdit::setDate ( const QDate &  date)

Sets the date for the widget and handles null dates.

Note
Since QDateTimeEdit::setDate() is not virtual, setDate must be called for QgsDateEdit.

Definition at line 451 of file qgsdatetimeedit.cpp.


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