Advertisement
Guest User

Untitled

a guest
Dec 29th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import QtQuick 2.0
  2. import Sailfish.Silica 1.0
  3.  
  4. Page {
  5. id: page
  6.  
  7. property var today: new Date() //todays date
  8. property var usrDate: new Date() //date that the user has picked
  9.  
  10. // Place our content in a Column. The PageHeader is always placed at the top
  11. // of the page, followed by our content.
  12. Column {
  13. id: column
  14. width: page.width
  15. spacing: Theme.paddingLarge
  16. PageHeader {
  17. title: "Age Calculator"
  18. }
  19.  
  20. Label{ //shows todays date 29/12/2013
  21. text: "Today is: " + today.getFullYear() + " / " + today.getMonth() + " / " + today.getDate()
  22. }
  23.  
  24. Button {
  25. id: button
  26. text: "Choose a date"
  27.  
  28. onClicked: {
  29. var dialog = pageStack.push("Sailfish.Silica.DatePickerDialog", {
  30. date: new Date() //uses today date by default 29/12/2013
  31. })
  32. dialog.accepted.connect(function() {
  33. usrDate = dialog
  34. button.text = "You chose: " + dialog.day
  35. //console.log("User day: ", usrDate.day)
  36. })
  37. }
  38. }
  39.  
  40. Label{ //shows in console: "TypeError: Cannot read property 'year' of null"
  41. text: "User picked: " + usrDate.year + " / " + usrDate.month + " / " + usrDate.day
  42. }
  43.  
  44. Button { //shows in console: "TypeError: Cannot read property 'year' of null"
  45. id: button2
  46. text: "Test user date"
  47.  
  48. onClicked: {
  49. button2.text = "User picked: " + usrDate.year + " / " + usrDate.month + " / " + usrDate.day
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement