dynamicly access ui-elements
Unsolved
Language Bindings
-
Hi,
I have a number of label-elements in my UI which I want to access dynamicly from a foreach().
Is there a way to do it?I have tried like
int i = 0; foreach(const QString &str, patternSlices) { i++; ui->step_(i)->blablablablabla(); }
I'm searching all the time, but can't figure it out how to do that :/
-
Hi,
thank you for the quick answer, but I don't get it :/
how should findChildren() get me the correct label-element? -
Thank you :)
it took me a while, until I finally got it working :)
int i = 0; foreach(const QString &str, patternSlices) { i++; QString labelName = QString("step_%1").arg(i); QLabel* label = findChild<QLabel*>(labelName); if(label) { label->setPixmap(otherStep.scaled(100,100, Qt::KeepAspectRatio)); } }