KDateTimeEdit Class
A widget for editing date and time. More...
- Header:
#include <KDateTimeEdit> - CMake:
find_package(KF6 REQUIRED COMPONENTS WidgetsAddons)
target_link_libraries(mytarget PRIVATE KF6::WidgetsAddons) - Inherits: QWidget
List of all members, including inherited members
Public Types
Properties
Public Functions
- KDateTimeEdit(QWidget *parent = nullptr)
- QList<QLocale> calendarLocalesList() const
- QDate date() const
- QLocale::FormatType dateDisplayFormat() const
- QMap<QDate, QString> dateMap() const
- QDateTime dateTime() const
- bool isNull() const
- bool isNullDate() const
- bool isNullTime() const
- bool isValid() const
- bool isValidDate() const
- bool isValidTime() const
- QDateTime maximumDateTime() const
- QDateTime minimumDateTime() const
- KDateTimeEdit::Options options() const
- QTime time() const
- QLocale::FormatType timeDisplayFormat() const
- QList<QTime> timeList() const
- int timeListInterval() const
- QTimeZone timeZone() const
- QList<QTimeZone> timeZones() const
Public Slots
- void resetDateTimeRange()
- void resetMaximumDateTime()
- void resetMinimumDateTime()
- void setCalendarLocalesList(const QList<QLocale> &calendarLocales)
- void setDate(const QDate &date)
- void setDateDisplayFormat(QLocale::FormatType format)
- void setDateMap(QMap<QDate, QString> dateMap)
- void setDateTime(const QDateTime &dateTime)
- void setDateTimeRange(const QDateTime &minDateTime, const QDateTime &maxDateTime, const QString &minWarnMsg = QString(), const QString &maxWarnMsg = QString())
- void setMaximumDateTime(const QDateTime &maxDateTime, const QString &maxWarnMsg = QString())
- void setMinimumDateTime(const QDateTime &minDateTime, const QString &minWarnMsg = QString())
- void setOptions(KDateTimeEdit::Options options)
- void setTime(const QTime &time)
- void setTimeDisplayFormat(QLocale::FormatType format)
- void setTimeList(QList<QTime> timeList, const QString &minWarnMsg = QString(), const QString &maxWarnMsg = QString())
- void setTimeListInterval(int minutes)
- void setTimeZone(const QTimeZone &zone)
- void setTimeZones(const QList<QTimeZone> &zones)
Signals
- void calendarChanged(const QLocale &calendarLocale)
- void calendarEntered(const QLocale &calendarLocale)
- void dateChanged(const QDate &date)
- void dateEdited(const QDate &date)
- void dateEntered(const QDate &date)
- void dateTimeChanged(const QDateTime &dateTime)
- void dateTimeEdited(const QDateTime &dateTime)
- void dateTimeEntered(const QDateTime &dateTime)
- void timeChanged(const QTime &time)
- void timeEdited(const QTime &time)
- void timeEntered(const QTime &time)
- void timeZoneChanged(const QTimeZone &zone)
- void timeZoneEntered(const QTimeZone &zone)
Protected Functions
- void assignDate(const QDate &date)
- void assignDateTime(const QDateTime &dateTime)
- void assignTime(const QTime &time)
- void assignTimeZone(const QTimeZone &zone)
Detailed Description
Member Type Documentation
enum KDateTimeEdit::Option
flags KDateTimeEdit::Options
Options provided by the widget
| Constant | Value | Description |
|---|---|---|
KDateTimeEdit::ShowCalendar |
0x00001 |
If the Calendar System edit is displayed |
KDateTimeEdit::ShowDate |
0x00002 |
If the Date is displayed |
KDateTimeEdit::ShowTime |
0x00004 |
If the Time is displayed |
KDateTimeEdit::ShowTimeZone |
0x00008 |
If the Time Zone is displayed |
KDateTimeEdit::EditDate |
0x00020 |
Allow the user to manually edit the date |
KDateTimeEdit::EditTime |
0x00040 |
Allow the user to manually edit the time |
KDateTimeEdit::SelectCalendar |
0x00100 |
Allow the user to select a calendar |
KDateTimeEdit::SelectDate |
0x00200 |
Allow the user to select a date |
KDateTimeEdit::SelectTime |
0x00400 |
Allow the user to select a time |
KDateTimeEdit::SelectTimeZone |
0x00800 |
Allow the user to select a time zone |
KDateTimeEdit::DatePicker |
0x01000 |
Show a date picker |
KDateTimeEdit::DateKeywords |
0x02000 |
Show date keywords |
KDateTimeEdit::ForceTime |
0x04000 |
The entered time can only be a selected time |
KDateTimeEdit::WarnOnInvalid |
0x08000 |
Show a warning on focus out if the date or time is invalid |
The Options type is a typedef for QFlags<Option>. It stores an OR combination of Option values.
See also options, setOptions, Options
Property Documentation
date : QDate
Access functions:
Notifier signal:
voiddateChanged(constQDate&date)
options : Options
Access functions:
KDateTimeEdit::Optionsoptions() constvoidsetOptions(KDateTimeEdit::Optionsoptions)
time : QTime
Access functions:
Notifier signal:
voidtimeChanged(constQTime&time)
timeListInterval : int
Access functions:
inttimeListInterval() constvoidsetTimeListInterval(intminutes)
Member Function Documentation
[explicit] KDateTimeEdit::KDateTimeEdit(QWidget *parent = nullptr)
Create a new KDateTimeEdit widget
[virtual protected] void KDateTimeEdit::assignDate(const QDate &date)
Assign the date for the widget.
Virtual to allow sub-classes to apply extra validation rules, but reimplementations must call the parent method at the end.
date the new date
[virtual protected] void KDateTimeEdit::assignDateTime(const QDateTime &dateTime)
Assign the date, time and time zone for the widget.
Virtual to allow sub-classes to apply extra validation rules, but reimplementations must call the parent method at the end.
dateTime the new date and time
[virtual protected] void KDateTimeEdit::assignTime(const QTime &time)
Assign the time for the widget.
Virtual to allow sub-classes to apply extra validation rules, but reimplementations must call the parent method at the end.
time the new time
[protected] void KDateTimeEdit::assignTimeZone(const QTimeZone &zone)
Assign the time zone for the widget.
Virtual to allow sub-classes to apply extra validation rules, but reimplementations must call the parent method at the end.
zone the new time zone
[signal] void KDateTimeEdit::calendarChanged(const QLocale &calendarLocale)
Signal if the Calendar Locale has been changed either manually by the user or programmatically.
calendarLocale the new calendar locale
[signal] void KDateTimeEdit::calendarEntered(const QLocale &calendarLocale)
Signal if the Calendar Locale has been manually entered by the user.
calendarLocale the new calendar locale
QList<QLocale> KDateTimeEdit::calendarLocalesList() const
Returns the list of Calendar Locales displayed.
See also setCalendarLocalesList()
QDate KDateTimeEdit::date() const
Return the currently selected date
Note: Getter function for property date.
See also setDate()
[signal] void KDateTimeEdit::dateChanged(const QDate &date)
Signal if the date has been changed either manually by the user or programmatically.
The returned date may be invalid.
date the new date
Note: Notifier signal for property date.
QLocale::FormatType KDateTimeEdit::dateDisplayFormat() const
Return the currently set date display format
By default this is the Short Format
See also setDateDisplayFormat()
[signal] void KDateTimeEdit::dateEdited(const QDate &date)
Signal if the date is being manually edited by the user.
The returned date may be invalid.
date the new date
[signal] void KDateTimeEdit::dateEntered(const QDate &date)
Signal if the date has been manually entered by the user.
The returned date may be invalid.
date the new date
QMap<QDate, QString> KDateTimeEdit::dateMap() const
Return the map of dates listed in the drop-down and their displayed string forms.
See also setDateMap()
QDateTime KDateTimeEdit::dateTime() const
Return the currently selected date, time and time zone
See also setDateTime()
[signal] void KDateTimeEdit::dateTimeChanged(const QDateTime &dateTime)
Signal if the date or time has been changed either manually by the user or programmatically.
The returned date and time may be invalid.
dateTime the new date, time and time zone
[signal] void KDateTimeEdit::dateTimeEdited(const QDateTime &dateTime)
Signal if the date or time is being manually edited by the user.
The returned date and time may be invalid.
dateTime the new date, time and time zone
[signal] void KDateTimeEdit::dateTimeEntered(const QDateTime &dateTime)
Signal if the date or time has been manually entered by the user.
The returned date and time may be invalid.
dateTime the new date, time and time zone
bool KDateTimeEdit::isNull() const
Return if the current user input is null
See also isValid()
bool KDateTimeEdit::isNullDate() const
Return if the current user input date is null
See also isValidDate()
bool KDateTimeEdit::isNullTime() const
Return if the current user input time is null
See also isValidTime()
bool KDateTimeEdit::isValid() const
Return if the current user input is valid
If the user input is null then it is not valid
See also isNull()
bool KDateTimeEdit::isValidDate() const
Return if the current user input date is valid
If the user input date is null then it is not valid
See also isNullDate()
bool KDateTimeEdit::isValidTime() const
Return if the current user input time is valid
If the user input time is null then it is not valid
See also isNullTime()
QDateTime KDateTimeEdit::maximumDateTime() const
Return the current maximum date and time
See also setMaximumDateTime()
QDateTime KDateTimeEdit::minimumDateTime() const
Return the current minimum date and time
See also setMinimumDateTime()
KDateTimeEdit::Options KDateTimeEdit::options() const
Return the currently set widget options
Note: Getter function for property options.
See also setOptions()
[slot] void KDateTimeEdit::resetDateTimeRange()
Reset the minimum and maximum date and time to the default
[slot] void KDateTimeEdit::resetMaximumDateTime()
Reset the minimum date and time to the default
[slot] void KDateTimeEdit::resetMinimumDateTime()
Reset the minimum date and time to the default
[slot] void KDateTimeEdit::setCalendarLocalesList(const QList<QLocale> &calendarLocales)
Set the list of Calendar Locales to display.
calendarLocales the list of calendar locales to display
See also calendarLocalesList()
[slot] void KDateTimeEdit::setDate(const QDate &date)
Set the currently selected date
date the new date
Note: Setter function for property date.
See also date()
[slot] void KDateTimeEdit::setDateDisplayFormat(QLocale::FormatType format)
Sets the date format to display.
By default is the Short Format.
format the date format to use
See also dateDisplayFormat()
[slot] void KDateTimeEdit::setDateMap(QMap<QDate, QString> dateMap)
Set the list of dates able to be selected from the drop-down and the string form to display for those dates, e.g. "2010-01-01" and "Yesterday".
Any invalid or duplicate dates will be used, the list will NOT be sorted, and the minimum and maximum date will not be affected.
The dateMap is keyed by the date to be listed and the value is the string to be displayed. If you want the date to be displayed in the default date format then the string should be null. If you want a separator to be displayed then set the string to "separator".
dateMap the map of dates able to be selected
See also dateMap()
[slot] void KDateTimeEdit::setDateTime(const QDateTime &dateTime)
Set the currently selected date, time and time zone
dateTime the new date, time and time zone
See also dateTime()
[slot] void KDateTimeEdit::setDateTimeRange(const QDateTime &minDateTime, const QDateTime &maxDateTime, const QString &minWarnMsg = QString(), const QString &maxWarnMsg = QString())
Set the minimum and maximum date and time range
To enable range checking provide two valid dates. To disable range checking provide two invalid dates, or call clearDateRange;
minDateTime the minimum date and time
maxDateTime the maximum date and time
minWarnMsg the minimum warning message
maxWarnMsg the maximum warning message
[slot] void KDateTimeEdit::setMaximumDateTime(const QDateTime &maxDateTime, const QString &maxWarnMsg = QString())
Set the maximum allowed date.
If the date is invalid, or less than current minimum, then the maximum will not be set.
maxDateTime the maximum date
maxWarnMsg the maximum warning message
See also maximumDateTime(), setMinimumDateTime(), setDateRange()
[slot] void KDateTimeEdit::setMinimumDateTime(const QDateTime &minDateTime, const QString &minWarnMsg = QString())
Set the minimum allowed date.
If the date is invalid, or more than current maximum, then the minimum will not be set.
minDateTime the minimum date
minWarnMsg the minimum warning message
See also minimumDateTime(), setMaximumDateTime(), setDateRange()
[slot] void KDateTimeEdit::setOptions(KDateTimeEdit::Options options)
Set the new widget options
options the new widget options
Note: Setter function for property options.
See also options()
[slot] void KDateTimeEdit::setTime(const QTime &time)
Set the currently selected time
time the new time
Note: Setter function for property time.
See also time()
[slot] void KDateTimeEdit::setTimeDisplayFormat(QLocale::FormatType format)
Sets the time format to display.
By default is the Short Format.
format the time format to use
See also timeDisplayFormat()
[slot] void KDateTimeEdit::setTimeList(QList<QTime> timeList, const QString &minWarnMsg = QString(), const QString &maxWarnMsg = QString())
Set the list of times able to be selected from the drop-down.
Setting the time list will override any time interval previously set via setTimeListInterval().
Any invalid or duplicate times will be ignored, and the list will be sorted.
The minimum and maximum time will automatically be set to the earliest and latest value in the list.
timeList the list of times able to be selected
minWarnMsg the minimum warning message
maxWarnMsg the maximum warning message
See also timeList()
[slot] void KDateTimeEdit::setTimeListInterval(int minutes)
Set the interval between times able to be selected from the drop-down.
The combo drop-down will be populated with times every minutes apart, starting from the minimumTime() and ending at maximumTime().
If the ForceInterval option is set then any time manually typed into the combo line edit will be forced to the nearest interval.
This interval must be an exact divisor of the valid time range hours. For example with the default 24 hour range interval must divide 1440 minutes exactly, meaning 1, 6 and 90 are valid but 7, 31 and 91 are not.
Setting the time list interval will override any time list previously set via setTimeList().
minutes the time list interval to display
Note: Setter function for property timeListInterval.
See also timeListInterval()
[slot] void KDateTimeEdit::setTimeZone(const QTimeZone &zone)
Set the current time zone
zone the new zone
See also timeZone()
[slot] void KDateTimeEdit::setTimeZones(const QList<QTimeZone> &zones)
Set the time zones able to be selected
zones the time zones to display
See also timeZones()
QTime KDateTimeEdit::time() const
Return the currently selected time
Note: Getter function for property time.
See also setTime()
[signal] void KDateTimeEdit::timeChanged(const QTime &time)
Signal if the time has been changed either manually by the user or programmatically.
The returned time may be invalid.
time the new time
Note: Notifier signal for property time.
QLocale::FormatType KDateTimeEdit::timeDisplayFormat() const
Return the currently set time format
By default this is the Short Format
See also setTimeDisplayFormat()
[signal] void KDateTimeEdit::timeEdited(const QTime &time)
Signal if the time is being manually edited by the user.
The returned time may be invalid.
time the new time
[signal] void KDateTimeEdit::timeEntered(const QTime &time)
Signal if the time has been manually entered by the user.
The returned time may be invalid.
time the new time
QList<QTime> KDateTimeEdit::timeList() const
Return the list of times able to be selected in the drop-down.
See also setTimeList(), timeListInterval(), setTimeListInterval()
int KDateTimeEdit::timeListInterval() const
Return the time list interval able to be selected
Note: Getter function for property timeListInterval.
See also setTimeListInterval()
QTimeZone KDateTimeEdit::timeZone() const
Return the currently selected time zone
See also setTimeZone()
[signal] void KDateTimeEdit::timeZoneChanged(const QTimeZone &zone)
Signal if the time zone has been changed either manually by the user or programmatically.
zone the new time zone
[signal] void KDateTimeEdit::timeZoneEntered(const QTimeZone &zone)
Signal if the time zone has been changed manually by the user.
zone the new time zone
QList<QTimeZone> KDateTimeEdit::timeZones() const
Return the list of time zones able to be selected
See also setTimeZones()