Single command to disable all components
-
Hi all,
I have some entities on my page.qml that I need to disable. Is there a cleaner/faster way (e.g a single command) to disable all of them with a 1-line code instead of something like below? Thanks.
MyButton { ... onClicked: { ab.enabled = false ac.enabled = false ad.enabled = false ae.enabled = false af.enabled = false ag.enabled = false ah.enabled = false ai.enabled = false ... n.enabled = false }
-
Yes there are several ways to do it.
-
If your components are all children of a single item, you can disable that item and all children will be disabled automatically.
-
You can define a new property and make sure all interested items listen to it:
property bool itemsEnabled: true Item { enabled: itemsEnabled } Item { enabled: itemsEnabled } // etc. MyButton { onClicked: itemsEnabled = !itemsEnabled }
-
-
Yes there are several ways to do it.
-
If your components are all children of a single item, you can disable that item and all children will be disabled automatically.
-
You can define a new property and make sure all interested items listen to it:
property bool itemsEnabled: true Item { enabled: itemsEnabled } Item { enabled: itemsEnabled } // etc. MyButton { onClicked: itemsEnabled = !itemsEnabled }
-