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. Help with QList of Groupboxes and Checkboxes
Forum Updated to NodeBB v4.3 + New Features

Help with QList of Groupboxes and Checkboxes

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 2.7k 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.
  • B Offline
    B Offline
    bwcal1999
    wrote on 18 Oct 2016, 13:08 last edited by
    #1

    I am creating a form with over 100 groupboxes, and inside each of those groupboxes has 6 checkboxes. This is to control some hardware I built. This configuration is really the best option. I have created a QList of checkboxes for each groupbox. Now I would like to incorporate those 100 QLists in to another QList, presumable of groupboxes ie a 2d QList. I have done this and I check the size and it returns with the correct size. Now I am having trouble access each individual checkbox. Below is the code I am using.

    //Groups all the checkboxes in to a QList.  Eventuall end up with 100 Qlists 
    QList<QCheckBox *> allCheckBox1 = ui->groupBox_1->findChildren<QCheckBox *>();     
    QList<QCheckBox *> allCheckBox2 = ui->groupBox_2->findChildren<QCheckBox *>();
    .
    ..
    ...
    //shortened for brevity
     
    //This I believe is making a QList of all the above items. It returns the correct size when
    //when I call  "qDebug()<<mybox.size();"
    QList<QGroupBox *> mybox = ui->centralWidget->findChildren<QGroupBox *>();
    
    

    Now my problem is accessing the individual checkboxes to see what state they are at, how do I do this?

    I get as far as

     mybox.at(i)->
    

    But don't know where to go after that.

    Thank you for your time.

    R 1 Reply Last reply 18 Oct 2016, 13:18
    0
    • B bwcal1999
      18 Oct 2016, 13:08

      I am creating a form with over 100 groupboxes, and inside each of those groupboxes has 6 checkboxes. This is to control some hardware I built. This configuration is really the best option. I have created a QList of checkboxes for each groupbox. Now I would like to incorporate those 100 QLists in to another QList, presumable of groupboxes ie a 2d QList. I have done this and I check the size and it returns with the correct size. Now I am having trouble access each individual checkbox. Below is the code I am using.

      //Groups all the checkboxes in to a QList.  Eventuall end up with 100 Qlists 
      QList<QCheckBox *> allCheckBox1 = ui->groupBox_1->findChildren<QCheckBox *>();     
      QList<QCheckBox *> allCheckBox2 = ui->groupBox_2->findChildren<QCheckBox *>();
      .
      ..
      ...
      //shortened for brevity
       
      //This I believe is making a QList of all the above items. It returns the correct size when
      //when I call  "qDebug()<<mybox.size();"
      QList<QGroupBox *> mybox = ui->centralWidget->findChildren<QGroupBox *>();
      
      

      Now my problem is accessing the individual checkboxes to see what state they are at, how do I do this?

      I get as far as

       mybox.at(i)->
      

      But don't know where to go after that.

      Thank you for your time.

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 18 Oct 2016, 13:18 last edited by
      #2

      @bwcal1999 said in Help with QList of Groupboxes and Checkboxes:

      ->findChildren<QGroupBox *>();

      do the same with QCheckBox* on the groupbox?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      B 1 Reply Last reply 18 Oct 2016, 13:24
      0
      • R raven-worx
        18 Oct 2016, 13:18

        @bwcal1999 said in Help with QList of Groupboxes and Checkboxes:

        ->findChildren<QGroupBox *>();

        do the same with QCheckBox* on the groupbox?

        B Offline
        B Offline
        bwcal1999
        wrote on 18 Oct 2016, 13:24 last edited by
        #3

        @raven-worx
        aren’t I?

        R 1 Reply Last reply 18 Oct 2016, 13:27
        0
        • B bwcal1999
          18 Oct 2016, 13:24

          @raven-worx
          aren’t I?

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 18 Oct 2016, 13:27 last edited by
          #4

          @bwcal1999 said in Help with QList of Groupboxes and Checkboxes:

          aren’t I?

          you wrote:

          @bwcal1999 said in Help with QList of Groupboxes and Checkboxes:

          I get as far as

          mybox.at(i)->

          But don't know where to go after that.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          B 1 Reply Last reply 18 Oct 2016, 13:34
          0
          • R raven-worx
            18 Oct 2016, 13:27

            @bwcal1999 said in Help with QList of Groupboxes and Checkboxes:

            aren’t I?

            you wrote:

            @bwcal1999 said in Help with QList of Groupboxes and Checkboxes:

            I get as far as

            mybox.at(i)->

            But don't know where to go after that.

            B Offline
            B Offline
            bwcal1999
            wrote on 18 Oct 2016, 13:34 last edited by
            #5

            @raven-worx

            If it worked I wouldn’t be writing this :)

            Below acceses one group box. But how to I access a checkbox of that group box?
            mybox.at(i)->

            I tried mybox.at(i)[j].isChecked but this doesn’t work either.

            M 1 Reply Last reply 18 Oct 2016, 13:43
            0
            • B bwcal1999
              18 Oct 2016, 13:34

              @raven-worx

              If it worked I wouldn’t be writing this :)

              Below acceses one group box. But how to I access a checkbox of that group box?
              mybox.at(i)->

              I tried mybox.at(i)[j].isChecked but this doesn’t work either.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 18 Oct 2016, 13:43 last edited by mrjj
              #6

              @bwcal1999
              Hi unless the groupbox has a layout assigned
              I think checkboxes are just just members of mainwindow. (owned by)
              Not inside QGroupBox. IF it has layout, you can ask Layout for them.

              R 1 Reply Last reply 18 Oct 2016, 13:48
              0
              • M mrjj
                18 Oct 2016, 13:43

                @bwcal1999
                Hi unless the groupbox has a layout assigned
                I think checkboxes are just just members of mainwindow. (owned by)
                Not inside QGroupBox. IF it has layout, you can ask Layout for them.

                R Offline
                R Offline
                raven-worx
                Moderators
                wrote on 18 Oct 2016, 13:48 last edited by
                #7

                @mrjj

                mybox.at(i)->findChildren<QCheckBox*>()
                

                should do what you want, no?

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                M 1 Reply Last reply 18 Oct 2016, 13:50
                0
                • R raven-worx
                  18 Oct 2016, 13:48

                  @mrjj

                  mybox.at(i)->findChildren<QCheckBox*>()
                  

                  should do what you want, no?

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 18 Oct 2016, 13:50 last edited by
                  #8

                  @raven-worx
                  Yes it should, even if in layout as far as i know.
                  :)

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    bwcal1999
                    wrote on 18 Oct 2016, 13:58 last edited by
                    #9

                    Great thank you that worked!

                    mybox.at(0)->findChildren<QCheckBox*>().at(0)->isChecked()
                    
                    1 Reply Last reply
                    0

                    1/9

                    18 Oct 2016, 13:08

                    • Login

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