Creating dynamic number of an object in panel (as parent)

Important: unclear posts may not receive useful answers.

Before posting

  • Get familiar with Markdown to format and structure your post
  • Be sure to update lvgl from the latest version from the master branch.
  • Be sure you have checked the FAQ and read the relevant part of the documentation.
  • If applicable use the Simulator to eliminate hardware related issues.

Delete this section if you read and applied the mentioned points.


how to create defined number of an object as a child on a panel as parrent. based on lvgl library the output of lv_label_create function is (lv_obj_t *). I want to create N number of Lables after the N was Defined. but using the below code results to Hardfault.

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

how to define a N number of an object (lable in my case) in a for loop function

What have you tried so far?

the below code

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*		    uint16_t NumberOfAlarms = 5;

		    lv_obj_t ** AlarmsLable_OBJ;

		    lv_obj_t ** AlarmsType_OBJ;

		    for(uint8_t i = 0; i < NumberOfAlarms; i++){

		    	*(AlarmsLable_OBJ + i) = lv_label_create(ui_ParamAlarmsChildPanel);

			    lv_obj_set_width(*(AlarmsLable_OBJ + i), LV_SIZE_CONTENT);   /// 1
			    lv_obj_set_height(*(AlarmsLable_OBJ + i), LV_SIZE_CONTENT);    /// 1*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

problem solved. it needs malloc function