I want to remove the widget and delete it. I am not inside a const method.
ChildSlot.DetachWidget()
returns
const TSharedPtr<SWidget>
so the const is for the smart pointer, not the content. Right?
ChildSlot.DetachWidget().Reset()
does not work, I get the following error message
cannot convert 'this' pointer from 'const TSharedPtr<SWidget,0>' to 'TSharedPtr<SWidget,0> &'
It makes sense, because “.Reset” would not just destroy the content but set the smart pointer to a state without valid content. And because the smart pointer is const, this is not allowed.
How do I do it right? Don’t tell me I have to cast the const away? I’d not like to have to do that.
Is perhaps my idea wrong? SHOULD I not be able to do it? If so, why?