cancel
Showing results for 
Search instead for 
Did you mean: 

How can I change the values for each child within a container?

tv9
Associate II

Hello,

 

I was wondering how can I change the values of each child within a container? For example, I have a container with 4 slider widgets. I want to be able to set the values of each slider using a for loop. Below shows a very simplified example of what I'm trying to achieve within Screen1View.cpp. I want to use array iteration instead of setting each slider value manually because I'll eventually have more than 10 sliders in the container.

 

Screen1View::Screen1View()
{

}
void Screen1View::setupScreen()
{
     int presets[4] = { 5, 10, 15, 20 };
     for (int i; i < 4; i++)
     {
         // in the container, each of the 4 slider widgets is being set to a preset value from an array
         containerSliders[i].setValue(presets[i]); 
     }
}

 

While looking into this more, I saw that containers have a forEachChild public function, but I am unsure how to use GenericCallback for this use case. If this is the way to go, can a simplified example be provided?

 

Thanks for the help in advance!

1 REPLY 1
GaetanGodart
ST Employee