Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - import QtQuick 2.0
 - import Sailfish.Silica 1.0
 - Page {
 - id: page
 - property var today: new Date() //todays date
 - property var usrDate: new Date() //date that the user has picked
 - // Place our content in a Column. The PageHeader is always placed at the top
 - // of the page, followed by our content.
 - Column {
 - id: column
 - width: page.width
 - spacing: Theme.paddingLarge
 - PageHeader {
 - title: "Age Calculator"
 - }
 - Label{ //shows todays date 29/12/2013
 - text: "Today is: " + today.getFullYear() + " / " + today.getMonth() + " / " + today.getDate()
 - }
 - Button {
 - id: button
 - text: "Choose a date"
 - onClicked: {
 - var dialog = pageStack.push("Sailfish.Silica.DatePickerDialog", {
 - date: new Date() //uses today date by default 29/12/2013
 - })
 - dialog.accepted.connect(function() {
 - button.text = "You chose: " + dialog.day
 - })
 - console.log("Today's day: ", today.getDate()) //shows 29/12/2013 :)
 - console.log("User day: ", dialog.day) //shows 29/12/2013 :(
 - usrDate = dialog //trying to copy user picked date to ursDate
 - }
 - }
 - Label{ // does show user picked day :) BUT shows in console: "TypeError: Cannot read property 'year' of null"
 - text: "User picked: " + usrDate.year + " / " + usrDate.month + " / " + usrDate.day
 - }
 - Button { // does not show user picked date :(, shows in console: "TypeError: Cannot read property 'year' of null"
 - id: button2
 - text: "Test user date"
 - onClicked: {
 - button2.text = "User picked: " + usrDate.year + " / " + usrDate.month + " / " + usrDate.day
 - }
 - }
 - }
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment