JustBobC
10th June 2016, 04:05
I need to change properties of a couple of hundred objects (mostly pushButtons) according to integer data. The code would look like this:
ui->pbN_20->setText(display_value);
ui->pbN_20->setStyleSheet("background-color: white");
ui->pbN_21->setStyleSheet("background-color: palegreen");
Having the integers 20 and 21, it takes an awful lot of switches and if else code to hook up with the code above.
It would be great if you could do something like:
int cellNumber = 20;
OName = "pbN_" + QString::number(cellNumber);
ui->OName->setText(display_value);
but a string is not a valid object name. So, is there some way of constructing a pointer to an object name that would accomplish this?
ui->pbN_20->setText(display_value);
ui->pbN_20->setStyleSheet("background-color: white");
ui->pbN_21->setStyleSheet("background-color: palegreen");
Having the integers 20 and 21, it takes an awful lot of switches and if else code to hook up with the code above.
It would be great if you could do something like:
int cellNumber = 20;
OName = "pbN_" + QString::number(cellNumber);
ui->OName->setText(display_value);
but a string is not a valid object name. So, is there some way of constructing a pointer to an object name that would accomplish this?