Use an array. Something like:
QButton *myButtons[16];
myButtons[0] = ui->p1;
myButtons[1] = ui->p2;
...
QButton *myButtons[16];
myButtons[0] = ui->p1;
myButtons[1] = ui->p2;
...
To copy to clipboard, switch view to plain text mode
(there are other more efficient ways to initialise the array depending on the scope of the array, but this will work regardless)
then you can do:
for (int i = 0; i < 16; i ++)
{
myButtons[i]->setText("something");
}
for (int i = 0; i < 16; i ++)
{
myButtons[i]->setText("something");
}
To copy to clipboard, switch view to plain text mode
Bookmarks