Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there a signal for "see if any existing QCheckBoxes have changed state"?
Qt 6.11 is out! See what's new in the release blog

Is there a signal for "see if any existing QCheckBoxes have changed state"?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 953 Views 2 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.
  • Dummie1138D Offline
    Dummie1138D Offline
    Dummie1138
    wrote on last edited by
    #1

    Hi. I have some checkboxes in a QTable that are created when the user adds more data.
    11cdfbb4-7331-4ff8-ae22-0dc5e13fa68a-image.png
    I want to be able to send a signal whenever any of these boxes are checked/unchecked. Is there a signal for this? I know there's a signal for each individual box, but I'm building and destroying the boxes quickly so I don't think I can use this method. I haven't figured out a good alternate way of doing this yet. Please let me know if more information is required.

    JonBJ 1 Reply Last reply
    0
    • Dummie1138D Dummie1138

      Hi. I have some checkboxes in a QTable that are created when the user adds more data.
      11cdfbb4-7331-4ff8-ae22-0dc5e13fa68a-image.png
      I want to be able to send a signal whenever any of these boxes are checked/unchecked. Is there a signal for this? I know there's a signal for each individual box, but I'm building and destroying the boxes quickly so I don't think I can use this method. I haven't figured out a good alternate way of doing this yet. Please let me know if more information is required.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Dummie1138

      Is there a signal for "see if any existing QCheckBoxes have changed state"?

      No. There is a signal for each box changing, or you can iterate the boxes comparing them to previously-stored state to see whether any have changed.

      but I'm building and destroying the boxes quickly so I don't think I can use this method.

      Something wrong here: if the buttons really were destroyed "quickly" there would not be any point having them/the user would not get a chance to interact with them.

      There is a QButtonGroup Class for logically grouping buttons like QCheckBoxes together, but I don't think it would help for your requirement, other than perhaps as a logical starting point.

      Dummie1138D 1 Reply Last reply
      1
      • JonBJ JonB

        @Dummie1138

        Is there a signal for "see if any existing QCheckBoxes have changed state"?

        No. There is a signal for each box changing, or you can iterate the boxes comparing them to previously-stored state to see whether any have changed.

        but I'm building and destroying the boxes quickly so I don't think I can use this method.

        Something wrong here: if the buttons really were destroyed "quickly" there would not be any point having them/the user would not get a chance to interact with them.

        There is a QButtonGroup Class for logically grouping buttons like QCheckBoxes together, but I don't think it would help for your requirement, other than perhaps as a logical starting point.

        Dummie1138D Offline
        Dummie1138D Offline
        Dummie1138
        wrote on last edited by
        #3

        @JonB

        if the buttons really were destroyed "quickly" there would not be any point having them/the user would not get a chance to interact with them.

        Ok, maybe not that quickly.

        Iteration is an option but I am not sure if I wanna have some iterating code going through the checked boxes' state running in the background all the time.

        JonBJ 1 Reply Last reply
        0
        • Dummie1138D Dummie1138

          @JonB

          if the buttons really were destroyed "quickly" there would not be any point having them/the user would not get a chance to interact with them.

          Ok, maybe not that quickly.

          Iteration is an option but I am not sure if I wanna have some iterating code going through the checked boxes' state running in the background all the time.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Dummie1138
          I really do not understand what you are trying to achieve.

          • If you want to run code (immediately) on any (one) checkbox changing state, do it in a slot.

          • For that, connect signal/slot for each checkbox. They can all connect to same slot if desired. If you do not want to connect each checkbox to a slot, you can presumably achieve this alternatively via an eventFilter.

          • If you want to run code "periodically" to examine current state of multiple checkboxes and compare against state previously saved, do it on e.g. a timer or whenever in your code, iterating the boxes to see their state.

          1 Reply Last reply
          1
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Dummie1138 If those checkboxes are just checkable items then model sends a dataChanged signal whenever an item is modified. If you connect to it you can check roles.contains(Qt::CheckStateRole) to see if it's the check state that changed.

            1 Reply Last reply
            2

            • Login

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