How to set default time for QML DatePicker?

int_ua

According to the API I should use date property, but with mode: "Hours|Minutes" the picker stays at 00:00. Is it possible somehow?

Sylvain Pineau

You can use a simple JavaScript Date Object to set a default value:

import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.Pickers 0.1

DatePicker {
    id: timePicker
    mode: "Hours|Minutes"
    date: new Date(0,0,0,8,5)
}

The Date object is used to work with dates and times.

Date objects are created with new Date().

There are four ways of instantiating a date:

var d = new Date();
var d = new Date(milliseconds);
var d = new Date(dateString);
var d = new Date(year, month, day, hours, minutes, seconds, milliseconds); 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related