Hello All,

I am a newbie in QML and I am trying to set the time through a Tumbler. The code for the Tumbler is
Qt Code:
  1. import QtQuick 2.12
  2. import QtQuick.Window 2.2
  3. import QtQuick.Controls 2.12
  4.  
  5. Rectangle {
  6. width: frame.implicitWidth + 10
  7. height: frame.implicitHeight + 10
  8.  
  9. function formatText(count, modelData) {
  10. var data = count === 12 ? modelData + 1 : modelData;
  11. return data.toString().length < 2 ? "0" + data : data;
  12. }
  13.  
  14. FontMetrics {
  15. id: fontMetrics
  16. }
  17.  
  18. Component {
  19. id: delegateComponent
  20.  
  21. Label {
  22. text: formatText(Tumbler.tumbler.count, modelData)
  23. opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2)
  24. horizontalAlignment: Text.AlignHCenter
  25. verticalAlignment: Text.AlignVCenter
  26. font.pixelSize: fontMetrics.font.pixelSize * 1.25
  27. }
  28. }
  29.  
  30. Frame {
  31. id: frame
  32. padding: 0
  33. anchors.centerIn: parent
  34.  
  35. Row {
  36. id: row
  37.  
  38. Tumbler {
  39. id: hoursTumbler
  40. model: 12
  41. delegate: delegateComponent
  42. }
  43.  
  44. Tumbler {
  45. id: minutesTumbler
  46. model: 60
  47. delegate: delegateComponent
  48. }
  49.  
  50. Tumbler {
  51. id: amPmTumbler
  52. model: ["AM", "PM"]
  53. delegate: delegateComponent
  54. }
  55. }
  56. }
  57. }
To copy to clipboard, switch view to plain text mode 

I am calling the time tumbler from another page
Qt Code:
  1. import QtQuick 2.9
  2. import QtQuick.Window 2.2
  3. import QtQuick.Controls 2.0
  4. import QtQuick.Particles 2.0
  5. import QtQuick.Layouts 1.0
  6. import QtQuick.Controls 1.3
  7. import Timebar 3.14
  8. //import "ChangeLanguageAndRegion.qml"
  9.  
  10.  
  11. Window {
  12. id: changedateandtime
  13. visible: true
  14. visibility: Window.FullScreen
  15. color: "#000000"
  16.  
  17. Item {
  18. id: timeChangeTumbler_item
  19. anchors.horizontalCenter: parent.horizontalCenter
  20. anchors.horizontalCenterOffset: -40
  21. anchors.verticalCenter: parent.verticalCenter
  22. anchors.verticalCenterOffset: 30
  23. height: 200
  24. width: 180
  25.  
  26. TimeTumbler {
  27. id: timeTumbler
  28. anchors.rightMargin: 0
  29. anchors.bottomMargin: -1
  30. anchors.leftMargin: 0
  31. anchors.topMargin: 1
  32. // border.width: 0
  33. }
  34. }
  35. Item {
  36. id: doneandcancel
  37. anchors.horizontalCenter: parent.horizontalCenter
  38. y: 420
  39. width: 120
  40. height: 50
  41.  
  42. Image {
  43. id: donetickmark
  44. anchors.left: parent.left
  45. anchors.top: parent.top
  46. anchors.bottom: parent.bottom
  47. width: parent.width/3
  48. fillMode: Image.PreserveAspectFit
  49. source: "resources/TickmarkIcon.png"
  50. }
  51. Button {
  52. id: donebutton
  53. anchors.left: passkey.left
  54. anchors.right: passkey.right
  55. anchors.bottom: passkey.bottom
  56. anchors.top: passkey.top
  57. anchors.topMargin: -20
  58. anchors.leftMargin: -20
  59. opacity: 0
  60.  
  61. onClicked: {
  62. //save changes
  63. var hour = timeTumbler.currentIndex;
  64. mainLoader.source = 'Dashboard_2.qml';
  65. }
  66. }
  67.  
  68. Image {
  69. id: cancelcross
  70. anchors.right: parent.right
  71. anchors.top: parent.top
  72. anchors.bottom: parent.bottom
  73. width: parent.width/3
  74. fillMode: Image.PreserveAspectFit
  75. source: "resources/CrossIcon.png"
  76. }
  77. Button {
  78. id: cancelbutton
  79. anchors.left: log.left
  80. anchors.right: log.right
  81. anchors.bottom: log.bottom
  82. anchors.top: log.top
  83. anchors.topMargin: -20
  84. anchors.rightMargin: -20
  85. opacity: 0
  86.  
  87. onClicked: {
  88.  
  89. mainLoader.source = 'Dashboard_2.qml';
  90. }
  91.  
  92. }
  93.  
  94. }
To copy to clipboard, switch view to plain text mode 
When I press on the Done button I would like to get the hour from the hour column of the tumbler but I don't get anything. I am using the id : timeTumbler to access it but how can I get to the hours column and retrieve the index ?