for ( auto index; index < numberOfCheckBoxes; ++index )
connect( list_check_box[ index ], &QCheckBox::toggled, this, &MyWidget::onCheckboxToggled );
for ( auto index; index < numberOfCheckBoxes; ++index )
connect( list_check_box[ index ], &QCheckBox::toggled, this, &MyWidget::onCheckboxToggled );
To copy to clipboard, switch view to plain text mode
Of course, you can't call connect() until after you have created all of your checkboxes and put them into the QList.
int whichBox = list_check_box.indexOf( pCB );
QCheckBox * pCB = qobject_cast< QCheckBox * >( sender() );
int whichBox = list_check_box.indexOf( pCB );
To copy to clipboard, switch view to plain text mode
list_check_box should be defined as "QList< QCheckBox *>" so you use "." to call methods, not "->". There is no reason to define list_check_box as a "QList<QCheckBox *> *".
Bookmarks