Clock.qml 1.5 KB

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