Each button is a QObject and has an objectName(), and Designer sets the objectName() to match the name you see on the Object Inspector panel. You can iterate over QPushButton children of the form (or some child widget containing the buttons) where the name matches a pattern, extract the numeric part and use that as the ID. Something like:
Qt Code:
  1. ui->setupUi(this);
  2.  
  3. const QRegExp re("aux1_button(\\d+)");
  4. foreach(QPushButton *button, findChildren<QPushButton*>(re)) {
  5. (void) re.indexIn(button->objectName()); // we know it matches, but we need the captured text
  6. const int id = re.cap(1).toInt();
  7. ui->buttonGroup->setId(button, id); // assuming the button is already in the button group
  8. }
To copy to clipboard, switch view to plain text mode