Pages
API Documentation
On this page

KDateComboBox Class

A combobox for dates. More...

  • Header: #include <KDateComboBox>
  • CMake: find_package(KF6 REQUIRED COMPONENTS WidgetsAddons)
    target_link_libraries(mytarget PRIVATE KF6::WidgetsAddons)
  • Inherits: QComboBox

List of all members, including inherited members

Public Types

Properties

Public Functions

Public Slots

Signals

Protected Functions

Detailed Description

Member Type Documentation

enum KDateComboBox::Option

flags KDateComboBox::Options

Options provided by the widget

Constant Value Description
KDateComboBox::EditDate 0x0001 Allow the user to manually edit the date in the combo line edit
KDateComboBox::SelectDate 0x0002 Allow the user to select the date from a drop-down menu
KDateComboBox::DatePicker 0x0004 Show a date picker in the drop-down
KDateComboBox::DateKeywords 0x0008 Show date keywords in the drop-down
KDateComboBox::WarnOnInvalid 0x0010 Show a warning on focus out if the date is invalid

The Options type is a typedef for QFlags<Option>. It stores an OR combination of Option values.

See also options(), setOptions()

Property Documentation

date : QDate

Access functions:

Notifier signal:

maximumDate : QDate

Access functions:

minimumDate : QDate

Access functions:

options : Options

Access functions:

  • KDateComboBox::Options options() const
  • void setOptions(KDateComboBox::Options options)

Member Function Documentation

[explicit] KDateComboBox::KDateComboBox(QWidget *parent = nullptr)

Create a new KDateComboBox widget

By default the EditDate, SelectDate, DatePicker and DateKeywords options are enabled, the ShortDate format is used and the date is set to the current date.

[virtual protected] void KDateComboBox::assignDate(const QDate &date)

Assign the date for the widget.

Virtual to allow sub-classes to apply extra validation rules.

date the new date

QDate KDateComboBox::date() const

Return the currently selected date

Note: Getter function for property date.

See also setDate()

[signal] void KDateComboBox::dateChanged(const QDate &date)

Signal if the date has been changed either manually by the user or programmatically.

The emitted date may be invalid.

date the new date

Note: Notifier signal for property date.

[signal] void KDateComboBox::dateEdited(const QDate &date)

Signal if the date is being manually edited by the user.

The emitted date may be invalid, or may not yet be what the user intends as the final date.

date the new date

[signal] void KDateComboBox::dateEntered(const QDate &date)

Signal if the date has been manually entered (by typing a date and losing focus, or pressing Enter) or selected by the user (using the popup selector, or up, down, page up, page down keys, or the mouse wheel).

The emitted date may be invalid.

date the new date

QMap<QDate, QString> KDateComboBox::dateMap() const

Return the map of dates listed in the drop-down and their displayed string forms.

See also setDateMap()

QLocale::FormatType KDateComboBox::displayFormat() const

Return the currently set date display format

By default this is the Short Format

See also setDisplayFormat()

bool KDateComboBox::isNull() const

Return if the current user input is null

See also isValid()

bool KDateComboBox::isValid() const

Return if the current user input is valid

If the user input is null then it is not valid

See also isNull()

QDate KDateComboBox::maximumDate() const

Return the current maximum date

Note: Getter function for property maximumDate.

See also setMaximumDate()

QDate KDateComboBox::minimumDate() const

Return the current minimum date

Note: Getter function for property minimumDate.

See also setMinimumDate()

KDateComboBox::Options KDateComboBox::options() const

Return the currently set widget options

Note: Getter function for property options.

See also setOptions()

[slot] void KDateComboBox::resetDateRange()

Reset the minimum and maximum date to the default values.

See also setDateRange()

[slot] void KDateComboBox::resetMaximumDate()

Reset the maximum date to the default

The default is to have no maximum date.

Note: Resetter function for property maximumDate.

[slot] void KDateComboBox::resetMinimumDate()

Reset the minimum date to the default.

The default is to have no minimum date.

Note: Resetter function for property minimumDate.

[slot] void KDateComboBox::setDate(const QDate &date)

Set the currently selected date

You can set an invalid date or a date outside the valid range, validity checking is only done via isValid().

date the new date

Note: Setter function for property date.

See also date()

[slot] void KDateComboBox::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 KDateComboBox::setDateRange(const QDate &minDate, const QDate &maxDate, const QString &minWarnMsg = QString(), const QString &maxWarnMsg = QString())

Set the valid date range to be applied by isValid().

Both dates must be valid and the minimum date must be less than or equal to the maximum date, otherwise the date range will not be set.

minDate the minimum date

maxDate the maximum date

minWarnMsg the minimum warning message

maxWarnMsg the maximum warning message

[slot] void KDateComboBox::setDisplayFormat(QLocale::FormatType format)

Sets the date format to display.

By default is the Short Format.

format the date format to use

See also displayFormat()

[slot] void KDateComboBox::setMaximumDate(const QDate &maxDate, 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.

maxDate the maximum date

maxWarnMsg the maximum warning message

Note: Setter function for property maximumDate.

See also minimumDate(), maximumDate(), setMaximumDate(), setDateRange()

[slot] void KDateComboBox::setMinimumDate(const QDate &minDate, const QString &minWarnMsg = QString())

Set the minimum allowed date.

If the date is invalid, or greater than current maximum, then the minimum will not be set.

minDate the minimum date

minWarnMsg the minimum warning message

Note: Setter function for property minimumDate.

See also minimumDate(), maximumDate(), setMaximumDate(), setDateRange()

[slot] void KDateComboBox::setOptions(KDateComboBox::Options options)

Set the new widget options

options the new widget options

Note: Setter function for property options.

See also options()

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.