QGIS API Documentation  3.4.15-Madeira (e83d02e274)
Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
QgsDateTimeEdit Class Reference

The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times. More...

#include <qgsdatetimeedit.h>

Inheritance diagram for QgsDateTimeEdit:
Inheritance graph
[legend]

Signals

void valueChanged (const QDateTime &date)
 signal emitted whenever the value changes. More...
 

Public Member Functions

 QgsDateTimeEdit (QWidget *parent=nullptr)
 Constructor for QgsDateTimeEdit The current date and time is used by default. More...
 
bool allowNull () const
 If the widget allows setting null date/time. More...
 
void clear () override
 Set the current date as NULL. More...
 
QDateTime dateTime () const
 dateTime returns the date time which can eventually be a null date/time More...
 
void setAllowNull (bool allowNull)
 Determines if the widget allows setting null date/time. More...
 
void setDateTime (const QDateTime &dateTime)
 setDateTime set the date time in the widget and handles null date times. More...
 
void setEmpty ()
 Resets the widget to show no value (ie, an "unknown" state). More...
 

Protected Member Functions

void focusOutEvent (QFocusEvent *event) override
 
void mousePressEvent (QMouseEvent *event) override
 
void showEvent (QShowEvent *event) override
 
void wheelEvent (QWheelEvent *event) override
 

Properties

bool allowNull
 

Detailed Description

The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times.

Warning
You should use the signal valueChanged of this subclass rather than QDateTimeEdit::dateTimeChanged. If you consequently connect parent's dateTimeChanged signal and call dateTime() afterwards there is no warranty to have a proper NULL value handling.

Definition at line 32 of file qgsdatetimeedit.h.

Constructor & Destructor Documentation

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

Constructor for QgsDateTimeEdit The current date and time is used by default.

The widget is allowing null by default.

Definition at line 31 of file qgsdatetimeedit.cpp.

Member Function Documentation

bool QgsDateTimeEdit::allowNull ( ) const
inline

If the widget allows setting null date/time.

See also
setAllowNull

Definition at line 56 of file qgsdatetimeedit.h.

void QgsDateTimeEdit::clear ( )
override

Set the current date as NULL.

Note
if the widget is not configured to accept NULL dates, this will have no effect

Definition at line 59 of file qgsdatetimeedit.cpp.

QDateTime QgsDateTimeEdit::dateTime ( ) const

dateTime returns the date time which can eventually be a null date/time

Note
You mustn't call date() or time() because they can't return a NULL value.
since QDateTimeEdit::dateTime() is not virtual, dateTime must be called for QgsDateTimeEdit

Definition at line 267 of file qgsdatetimeedit.cpp.

void QgsDateTimeEdit::focusOutEvent ( QFocusEvent *  event)
overrideprotected

Definition at line 146 of file qgsdatetimeedit.cpp.

void QgsDateTimeEdit::mousePressEvent ( QMouseEvent *  event)
overrideprotected

Definition at line 92 of file qgsdatetimeedit.cpp.

void QgsDateTimeEdit::setAllowNull ( bool  allowNull)

Determines if the widget allows setting null date/time.

See also
allowNull

Definition at line 52 of file qgsdatetimeedit.cpp.

void QgsDateTimeEdit::setDateTime ( const QDateTime &  dateTime)

setDateTime set the date time in the widget and handles null date times.

Note
since QDateTimeEdit::setDateTime() is not virtual, setDateTime must be called for QgsDateTimeEdit.

Definition at line 250 of file qgsdatetimeedit.cpp.

void QgsDateTimeEdit::setEmpty ( )

Resets the widget to show no value (ie, an "unknown" state).

Since
QGIS 2.16

Definition at line 86 of file qgsdatetimeedit.cpp.

void QgsDateTimeEdit::showEvent ( QShowEvent *  event)
overrideprotected

Definition at line 173 of file qgsdatetimeedit.cpp.

void QgsDateTimeEdit::valueChanged ( const QDateTime &  date)
signal

signal emitted whenever the value changes.

Parameters
datethe new date/time value.
void QgsDateTimeEdit::wheelEvent ( QWheelEvent *  event)
overrideprotected

Definition at line 163 of file qgsdatetimeedit.cpp.

Property Documentation

bool QgsDateTimeEdit::allowNull
readwrite

Definition at line 35 of file qgsdatetimeedit.h.


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