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

Help with QList of Groupboxes and Checkboxes

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 2.7k Views
  • 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 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.

    raven-worxR 1 Reply Last reply
    0
    • B bwcal1999

      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.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on 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
      0
      • raven-worxR raven-worx

        @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 last edited by
        #3

        @raven-worx
        aren’t I?

        raven-worxR 1 Reply Last reply
        0
        • B bwcal1999

          @raven-worx
          aren’t I?

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on 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
          0
          • raven-worxR raven-worx

            @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 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.

            mrjjM 1 Reply Last reply
            0
            • B bwcal1999

              @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.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on 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.

              raven-worxR 1 Reply Last reply
              0
              • mrjjM mrjj

                @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.

                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on 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

                mrjjM 1 Reply Last reply
                0
                • raven-worxR raven-worx

                  @mrjj

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

                  should do what you want, no?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 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 last edited by
                    #9

                    Great thank you that worked!

                    mybox.at(0)->findChildren<QCheckBox*>().at(0)->isChecked()
                    
                    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 Extensions
                    • Unsolved