Advertisement
socphoenix

Qml Calendar

Mar 2nd, 2023
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Layouts
  4.  
  5. Window {
  6. width: 640
  7. height: 480
  8. visible: true
  9. title: qsTr("Hello World")
  10. property var monthStrings: ["Jan ", "Feb ", "Mar ", "Apr ", "May ", "Jun ", "Jul ", "Aug ", "Sept ", "Oct ", "Nov ", "Dec "]
  11.  
  12. Rectangle {
  13. width: 300
  14. height: 300
  15. anchors {
  16. top: parent.top
  17. horizontalCenter: parent.horizontalCenter
  18. }
  19.  
  20. color: "pink"
  21. ColumnLayout {
  22. width: 300
  23. height: 300
  24. anchors {
  25. top: parent.top
  26. horizontalCenter: parent.horizontalCenter
  27. }
  28. Grid {
  29. Button {
  30. text: "back a month"
  31. onClicked: {
  32. if(months.month === 0) {
  33. months.month = 11
  34. months.year = months.year -1
  35. }
  36. else months.month = months.month -1
  37. }
  38. }
  39. Label {
  40. id: monthlist
  41. text: monthStrings[months.month] + months.year
  42. }
  43.  
  44. Button {
  45. text: "Forward a month"
  46. onClicked: {
  47. if(months.month === 11) {
  48. months.month = 0
  49. months.year = months.year + 1
  50. }
  51. else months.month = months.month + 1
  52. }
  53. }
  54. }
  55.  
  56. DayOfWeekRow {
  57. Layout.fillWidth: true
  58. }
  59. MonthGrid {
  60. id: months
  61. Layout.fillHeight: true
  62. Layout.fillWidth: true
  63. onClicked: {
  64. console.log(months.currentIndex)
  65. }
  66. }
  67. }
  68.  
  69. }
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement