Problem with Hidden flag

Hello :slight_smile:

I’m a beginner in LVGL and I try to hide or show some pictures on the screen.

I tried:

        lv_obj_set_flag(ui_CmpON,LV_OBJ_FLAG_HIDDEN,true);
        lv_obj_set_flag(ui_NoState,LV_OBJ_FLAG_HIDDEN,true);
        lv_obj_set_flag(ui_CmpOff,LV_OBJ_FLAG_HIDDEN,false);

but this is not compiling…
so I’ve added:

  //add flags
  lv_obj_add_flag(ui_CmpOff,LV_OBJ_FLAG_HIDDEN);
  lv_obj_add_flag(ui_CmpON,LV_OBJ_FLAG_HIDDEN);
  lv_obj_add_flag(ui_NoState,LV_OBJ_FLAG_HIDDEN);

in the setup but same problem…
this is the error that I get:

src/ecran_clim.cpp:194:9: note: suggested alternative: ‘lv_obj_has_flag’
lv_obj_set_flag(ui_CmpON,LV_OBJ_FLAG_HIDDEN,true);
^~~~~~~~~~~~~~~
lv_obj_has_flag
*** [.pio\build\esp32dev\src\ecran_clim.cpp.o] Error 1

I read the manual and they said:

Blockquote

Flags

There are some attributes which can be enabled/disabled by lv_obj_add/remove_flag(obj, LV_OBJ_FLAG_...) and lv_obj_set_flag(obj, LV_OBJ_FLAG_..., true/false)

Blockquote

But it doesn’t seems to be working…
Is someone can help??
Thank you for your time and your help

Based on your ui_ seems you use Squareline. Here you can set hidden flag by click. And Syntax for cmds is based on versions lvgl 7 differ to 8 and now 9 is unsuported in SQS.
You dont show error for right syntx8 lv_obj_add_flag(

void lv_obj_set_hidden(lv_obj_t* obj, bool en){
#if LVGL_VERSION_MAJOR == 9
  (en)? lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN) : lv_obj_remove_flag(obj, LV_OBJ_FLAG_HIDDEN);
#elif LVGL_VERSION_MAJOR == 8
  (en)? lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN) : lv_obj_clear_flag(obj, LV_OBJ_FLAG_HIDDEN);
#endif
}

bool lv_obj_get_hidden(lv_obj_t* obj){
  return lv_obj_has_flag(obj, LV_OBJ_FLAG_HIDDEN);
}


Hi Marian, Yes, I’m using Squareline (fantastic program)…
Yes, no error on lv_obj_add_flag( but it doesn’t compile with : lv_obj_set_flag(ui_CmpON,LV_OBJ_FLAG_HIDDEN,true);

I will try the solution of @TridentTD and let you know.
Thank you for your help.

Thank you @TridentTD it works as expected. Short answer, extremely precise and totally correct as usual.
You’re really good Triden.

I can put only one heart on your answer but i will happily put 2 or 3 if I could :slight_smile:

Thank you again for your help and your time…

I’m living in Thailand and it’s SongKran day today… this is a new year Thai. So, Happy new year Tritent.

Have a lovely day.

Happy Songkran, Thailand’s New Year Water Festival!
It’s scorching hot in Thailand now,
but refreshing splashes of water make it cool.

Let’s celebrate!

You seems to know what you’re talking about :blush:
Yes, funny time, really hot, around 35 C but feel like 45… :face_with_spiral_eyes:

But anyway, we will celebrate :partying_face: