Clock.qml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import QtQuick 2.6
  2. Widget {
  3. id: root
  4. width: childrenRect.width
  5. height: clockLabel.height
  6. QtObject {
  7. id: d
  8. property string timeString
  9. property int day
  10. property int month
  11. function timeChanged() {
  12. var date = new Date;
  13. timeString = Qt.formatDateTime(date, "hh:mm")
  14. day = Qt.formatDateTime(date, "dd")
  15. month = Qt.formatDateTime(date, "MM")
  16. }
  17. }
  18. Timer {
  19. interval: 10*1000; running: true; repeat: true;
  20. onTriggered: d.timeChanged()
  21. }
  22. Text {
  23. //anchors.centerIn: parent
  24. id: clockLabel
  25. color: "white"
  26. font.bold: true
  27. font.pixelSize: 100
  28. text: d.timeString
  29. }
  30. Item {
  31. anchors { left: clockLabel.right; leftMargin: 20 }
  32. height: root.height
  33. width: childrenRect.width
  34. Item {
  35. width: childrenRect.width
  36. height: parent.height/2
  37. Text {
  38. anchors.centerIn: parent
  39. color: "white"
  40. font.bold: true
  41. verticalAlignment: Text.AlignVCenter
  42. horizontalAlignment: Text.AlignHCenter
  43. font.pixelSize: root.height/3
  44. text: d.day
  45. }
  46. }
  47. Item {
  48. y: parent.height/2
  49. width: childrenRect.width
  50. height: parent.height/2
  51. Text {
  52. anchors.centerIn: parent
  53. color: "white"
  54. font.bold: true
  55. verticalAlignment: Text.AlignVCenter
  56. horizontalAlignment: Text.AlignHCenter
  57. font.pixelSize: root.height/3
  58. text: d.month
  59. }
  60. }
  61. }
  62. }