Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Single command to disable all components
Qt 6.11 is out! See what's new in the release blog

Single command to disable all components

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ACaldas
    wrote on last edited by
    #1

    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
    }
    
    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Yes there are several ways to do it.

      1. If your components are all children of a single item, you can disable that item and all children will be disabled automatically.

      2. 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
      }
      

      (Z(:^

      A 1 Reply Last reply
      2
      • sierdzioS sierdzio

        Yes there are several ways to do it.

        1. If your components are all children of a single item, you can disable that item and all children will be disabled automatically.

        2. 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
        }
        
        A Offline
        A Offline
        ACaldas
        wrote on last edited by
        #3

        @sierdzio Thank you so much!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved