title: Getting state of QCheckBox in a QGridLayout?
body: <p>I have a simple layout to get/set states of IOs of an USB board.
  Each row corresponds to a module and column to an IO pin.
  THe purpose is to set states of outputs on one row, and see if the inputs match the ones checked on another row.</p>
  
  <p>I made this to setup the layout</p>
  
  <pre><code>QLabel * templab = new QLabel;
  templab -&gt;setText(QString("Broche -&gt;"));
  gridLayout_2-&gt;addWidget(templab, 0, 0);
  for (int row = 1; row &lt; modules+1 ;row++)
  {
      QLabel * templab = new QLabel;
      templab -&gt;setText(QString("Module %1").arg(row-1));
      gridLayout_2-&gt;addWidget(templab, row, 0);
  }
  for (int col = 1; col &lt; colonnes+1 ;col++)
  {
      QLabel * templab = new QLabel;
      templab -&gt;setNum(col);
      gridLayout_2-&gt;addWidget(templab, 0, col);
  }
  for (int row = 1; row &lt; modules +1 ;row++)
  {
      for (int col = 1; col &lt; colonnes+1 ;col++)
      {
          QCheckBox* checkBox = new QCheckBox();
          gridLayout_2 -&gt;addWidget(checkBox,row,col);
      }
  }
  </code></pre>
  
  <p>How do I check the state of checkboxes ?</p>
  
  <p>I did not find any clue on how to get the state of a checkbox using gridLayout_2->itematposition(x,y)</p>
  
  <p>Thanks a lot.</p>
  
  <p>Edit: following Spyke advice, I used :</p>
  
  <pre><code>QCheckBox * checkBox = findChild&lt;QCheckBox*&gt;(ui-&gt;gridLayout_5-&gt;itemAtPosition(x,y)-&gt;widget()-&gt;objectName());
  </code></pre>
  
  <p>There's another way to do it that I discovered:</p>
  
  <pre><code>QCheckBox * ios[8][16];
  
   for (int row = 1; row &lt; modules +1 ;row++)
      {
          for (int col = 1; col &lt; colonnes+1 ;col++)
          {
              ios[row-1][col-1]= new QCheckBox();
              ui-&gt;gridLayout_5 -&gt;addWidget(ios[row-1][col-1],row,col);
          }
      }
  </code></pre>
  
  <p>and to test the state:</p>
  
  <pre><code>if (ios[x][y]-&gt;checkState() == Qt::Checked)
  {
      qDebug()&lt;&lt;"Checked"&lt;&lt;endl;
  }
  else
      qDebug()&lt;&lt;"UN Checked"&lt;&lt;endl;
  
  }
  </code></pre>