I would disable button after other button_click event and enable again after timer timeout. I tried with Timer and States with PropertyChanged, but it doesn't work.
How I can send a qml signal to reload/refresh the page?

When i click on id_button_add I would disable Id_button_edit and start a timer for 3 seconds. When the timer timeouts I enable already the id_button_edit.

Here is my code.

Qt Code:
  1. import QtQuick 2.0
  2. import QtQuick.Layouts 1.3
  3.  
  4. import "../items"
  5. import ch.example 1.0
  6.  
  7. Item {
  8. id: id_root
  9. z: 2
  10.  
  11. property bool prepare_delete: false
  12. property string button_edit_enable_state: "enabled"
  13.  
  14. anchors.left: parent ? parent.left : undefined
  15. anchors.right: parent ? parent.right : undefined
  16.  
  17. Connections {
  18. target: id_root.ListView.view
  19. onCurrentIndexChanged: {
  20. prepare_delete = false
  21. }
  22. }
  23.  
  24. function update_remove_enable() {
  25. id_button_remove.button_enabled = ui_resident_model.sourceModel.rowCount() > 1
  26. }
  27.  
  28. Component.onCompleted: {
  29. ui_resident_model.sourceModel.onRowsInserted.connect(update_remove_enable)
  30. ui_resident_model.sourceModel.onRowsRemoved.connect(update_remove_enable)
  31. update_remove_enable()
  32. }
  33.  
  34. Rectangle {
  35. anchors.fill: parent
  36.  
  37. color: "transparent"
  38. border {
  39. color: touchpanel_style.foreground_color
  40. width: touchpanel_style.line_width
  41. }
  42. }
  43.  
  44. RowLayout {
  45. anchors.left: parent.left
  46. anchors.margins: touchpanel_style.margin
  47. anchors.verticalCenter: parent.verticalCenter
  48.  
  49. .
  50. .
  51. .
  52. .
  53. }
  54.  
  55. RowLayout {
  56. id: id_content
  57. anchors.right: parent.right
  58. anchors.margins: touchpanel_style.margin
  59. anchors.verticalCenter: parent.verticalCenter
  60.  
  61. state: button_edit_enable_state
  62.  
  63. states: [
  64. State {
  65. name: "enabled"
  66. PropertyChanges { target: id_button_edit; enabled: true }
  67. },
  68. State {
  69. name: "disabled"
  70. PropertyChanges { target: id_button_edit; enabled: false }
  71. }
  72. ]
  73.  
  74. Timer {
  75. id: serviceListItemTimer
  76. interval: 3000
  77. running: false
  78. repeat: false
  79. onTriggered: {
  80. console.log("onTriggered")
  81. button_edit_enable_state = "enabled"
  82. }
  83. }
  84.  
  85. IconButton {
  86. id: id_button_edit
  87. objectName: "button_edit"
  88. Layout.fillHeight: true
  89. width: height
  90.  
  91. icon_factor: 1.35
  92. icon_source: "../icons/edit.png"
  93.  
  94. onButtonClick: {
  95. prepare_delete = false
  96. loader.source = "../service_menu/ResidentEdit.qml";
  97. loader.item.onCancel.connect(cancel_edit)
  98. loader.item.onTimeout.connect(timeout)
  99. loader.item.model = id_root.ListView.view.currentItem.resident_model
  100. }
  101.  
  102. function cancel_edit() {
  103. loader.source = ""
  104. }
  105. }
  106.  
  107. IconButton {
  108. id: id_button_add
  109. objectName: "button_add"
  110. Layout.fillHeight: true
  111. width: height
  112.  
  113. icon_factor: 1.35
  114. icon_source: "../icons/resident_add.svg"
  115.  
  116. onButtonClick: {
  117. console.log("btn_add")
  118. button_edit_enable_state = "disabled"
  119. serviceListItemTimer.start()
  120. //serviceListItemTimer.running = true
  121. var index = id_root.ListView.view.currentIndex;
  122. id_root.ListView.view.model.createItem(index);
  123. set_index(index);
  124. }
  125. }
  126. }
  127. }
To copy to clipboard, switch view to plain text mode