cancel
Showing results for 
Search instead for 
Did you mean: 

Create widgets in code instead of in the designer

KR51K
Associate III

Hello,

is it possible to create a container including other containers during runtime? Backgrouns is that I would like to display up to 20 sensor readings on the display. The inner container includes a background, title, measurement value, status... The layout of the container is the same for all sensors so I would like to have a create-method that creates all the containers and holds them in an array so that I can change e.g. colors just with the array index.

3 REPLIES 3

Hello @KR51K ,

You can create a custom container that includes all the elements and widgets you need, plus the functionalities (like changing the color in the user code file or "CustomContainer.cpp"). Then, you can use Scroll List to have as many instances as you want. 
you can read more about Custom Containers here:
https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/custom-containers

 

I hope this helps you, good luck

Mohammad MORADI
ST Software Developer | TouchGFX

Thanks for your answer, this was a big help (however, you should check the code examples on the linked page, they do not compile - at least the last example of the page since the contructor does not match to to the class name and it includes elements that are not included).

But I have an additional question: what is the best way to include this into an extisting screen that is generated by the designer? 

You're very welcome.
Oh I will check the code in the page again, thanks for notifying.

Honestly, I am a bit confused by your question. To use your custom containers in any screen (previously created ones or new ones) you can just add them from widget bar. The designer will generate the required codes.

Mohammad MORADI
ST Software Developer | TouchGFX