Hi!
Let's imagine an example: I want to have 8x8 labels in *.ui file for displaying figures in chess. Now, when I use designer and add labels, they have names like: label, label_2, label_3 and so on. And I want to have a function, which parameters are x and y and in this function I want to change label image of corresponding field. How can I do this? 64 conditions?
void changeLabelOf(int x, int y)
{
if (x==0 && y==0) ui->label->setPixmap(....);
if (x==1 && y==0) ui->label_2->setPixmap(....);
if (x==2 && y==0) ui->label_3->setPixmap(....);
.
.
.
}
void changeLabelOf(int x, int y)
{
if (x==0 && y==0) ui->label->setPixmap(....);
if (x==1 && y==0) ui->label_2->setPixmap(....);
if (x==2 && y==0) ui->label_3->setPixmap(....);
.
.
.
}
To copy to clipboard, switch view to plain text mode
Is there something like macro to do this? Someone know how can I deal with this situation?
Bookmarks