This is where i use this function:
I just use it to set an energy progress bar in a widget. It is too long to reproduce it in an empty project but i can link you exactly what i have done becouse i copied step by step these video tutorials: