API Documentation

Documentation for developing SailfishOS applications

DatePickerDialog QML Type

A dialog for selecting a date from a DatePicker More...

Import Statement: import Sailfish.Silica 1.0



Detailed Description

The DatePickerDialog type presents a DatePicker within a Dialog to enable the user to select a date using a calendar grid.

The dialog shows the currently selected date above the calendar grid. If the user accepts the dialog, the year, month, day and dateText properties are set according to the selected date; otherwise, these values are left unchanged.

Here is a simple time picker dialog, opened with PageStack::push(), with its date set to November 23, 2012:

 import QtQuick 2.2
 import Sailfish.Silica 1.0

 Button {
     id: button
     text: "Choose a date"

     onClicked: {
         var dialog = pageStack.push(pickerComponent, {
             date: new Date('2012/11/23')
         dialog.accepted.connect(function() {
             button.text = "You chose: " + dialog.dateText

     Component {
         id: pickerComponent
         DatePickerDialog {}

Note that if the date property is not set or is set to undefined, the dialog will show a year selection page when it opens.

The DatePickerDialog provides a convenient way to request a date value from the user through a dialog-type interface. If you require the calendar grid interface without the dialog container, use DatePicker instead.

See also TimePicker, DatePicker, and Dialog.

Property Documentation

date : date

The accepted date, as a JavaScript date object. This defaults to the current local date.

Note that a JavaScript date object's month value is 0-based. See DatePicker::date for more information.

See also DatePicker::date.

[read-only] dateText : string

Reports the accepted date as a formatted date string in the system short date format.

See also DatePicker::dateText.

[read-only] day : int

Reports the day of the accepted date, as a number in the range 1-31.

See also DatePicker::day.

[read-only] month : int

Reports the month of the accepted date, as a number in the range 1-12.

See also DatePicker::month.

[read-only] year : int

Reports the year of the accepted date, as a four-digit number.

See also DatePicker::year.

We use cookies to improve your user experience and to help us to develop our services. By continuing to browse the site, you approve of our use of cookies.