Advertisement
Guest User

Untitled

a guest
Dec 29th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  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. button.text = "You chose: " + dialog.day
  34. })
  35.  
  36. console.log("Today's day: ", today.getDate()) //shows 29/12/2013 :)
  37. console.log("User day: ", dialog.day) //shows 29/12/2013 :(
  38.  
  39. usrDate = dialog //trying to copy user picked date to ursDate
  40.  
  41. }
  42. }
  43.  
  44. Label{ // does show user picked day :) BUT shows in console: "TypeError: Cannot read property 'year' of null"
  45. text: "User picked: " + usrDate.year + " / " + usrDate.month + " / " + usrDate.day
  46. }
  47.  
  48. Button { // does not show user picked date :(, shows in console: "TypeError: Cannot read property 'year' of null"
  49. id: button2
  50. text: "Test user date"
  51.  
  52. onClicked: {
  53. button2.text = "User picked: " + usrDate.year + " / " + usrDate.month + " / " + usrDate.day
  54. }
  55. }
  56. }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement