Qt version: 4.4.3:


Consider the code:

Qt Code:
  1. QWidget *scrollAreaWidgetContents;
  2.  
  3. // ...
  4.  
  5.  
  6. // Used for the naming of the checkboxes
  7. unsigned count= 1;
  8.  
  9.  
  10. // Adds the checkboxes empty
  11. for(unsigned j= 1; j<= 8; ++j)
  12. {
  13. QCheckBox *checkBox= new QCheckBox(scrollAreaWidgetContents);
  14.  
  15. ++count;
  16.  
  17. checkBox->setObjectName(QString("checkBox_%1").arg(QString::number(count)));
  18. checkBox->setGeometry(QRect(50* (j+ 1)+ 37, 20* i, 83, 20));
  19. }
  20.  
  21. // ...
  22.  
  23.  
  24. switch(runLevelsInfostring[0])
  25. {
  26. case '0':
  27. scrollAreaWidgetContents.nextInFocusChain()->setCheckState(Qt::Checked);
  28. }
To copy to clipboard, switch view to plain text mode 

I want to make the checkbox named "checkBox_1", to become << checkBox_1->setCheckState(Qt::Checked); >> How can I do that?

Thanks.