#include <WDatePicker>
Public Member Functions | |
WDatePicker (WInteractWidget *displayWidget, WLineEdit *forEdit, bool i18n=false, WContainerWidget *parent=0) | |
Create a new date picker. | |
void | setFormat (const WString &format) |
Set the format used for parsing or writing the date in the line edit. | |
const WString & | format () const |
Get the format. | |
WCalendar * | calendar () const |
The calendar widget. | |
WLineEdit * | lineEdit () const |
The line edit. | |
WInteractWidget * | displayWidget () const |
The display widget. | |
WDate | date () const |
The current date. | |
void | setDate (const WDate &date) |
Set the current date. |
A date picker works in conjunction with a WLineEdit to popup a WCalendar for editing the date. The date picker itself is typically displayed as a button next to the line edit. When the user clicks the button, a calendar pops up which may be used to pick a new date. Any date entered in the line edit is reflected in the calendar, and vice-versa.
Each of these widgets may be accessed individually (lineEdit(), calendar(), and displayWidget()).
The date format used by default is 'dd/MM/yyyy', but can be changed using setFormat(). At any time, the date set may be read using date(), or can be changed using setDate().
WDatePicker using a WPushButton as displayWidget
Wt::WDatePicker::WDatePicker | ( | WInteractWidget * | displayWidget, | |
WLineEdit * | forEdit, | |||
bool | i18n = false , |
|||
WContainerWidget * | parent = 0 | |||
) |
Create a new date picker.
The displayWidget represents the button or image which much be clicked to open the date picker. This widget may not yet have a parent, and becomes owned by the picker.
The forEdit argument is the lineEdit which works in conjunction with the date picker. This widget is not part of the date picker, and may be located anywhere else.
i18n is passed to the WCalendar constructor.
void Wt::WDatePicker::setFormat | ( | const WString & | format | ) |
Set the format used for parsing or writing the date in the line edit.
Sets the format used for parsing the value of the lineEdit, or for setting the value of the lineEdit.
const WString& Wt::WDatePicker::format | ( | ) | const [inline] |
Get the format.
Get the current format used to parse dates from the lineEdit text, or to set the lineEdit text from a selected date in the calendar.
WCalendar* Wt::WDatePicker::calendar | ( | ) | const [inline] |
The calendar widget.
Returns the calendar widget.
WLineEdit* Wt::WDatePicker::lineEdit | ( | ) | const [inline] |
The line edit.
Returns the line edit which works in conjunction with this date picker.
WInteractWidget* Wt::WDatePicker::displayWidget | ( | ) | const [inline] |
The display widget.
Returns the widget which is displayed to activate the calendar.
WDate Wt::WDatePicker::date | ( | ) | const |
The current date.
Reads the current date from the lineEdit().
Returns an invalid date (for which WDate::isValid() returns false) if the date could not be parsed using the current format().
void Wt::WDatePicker::setDate | ( | const WDate & | date | ) |