UUserWidget::RemoveFromParent
#include "Blueprint/UserWidget.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableBlueprintCosmetic
Description
Removes this widget from its parent — either the viewport or a containing panel widget. The widget object is not destroyed; it can be re-added later.
Signature
virtual void RemoveFromParent() Return Type
void Caveats & Gotchas
- • RemoveFromViewport was deprecated in UE 5.1 in favour of RemoveFromParent, which works for both viewport-attached and panel-attached widgets.
- • Removing a widget does not destroy it or clear references. If no strong reference holds it, it will be GC'd eventually.
- • NativeDestruct / the Blueprint Destruct event fires when the widget is removed from the viewport, not when it is GC'd.
Example
Close a menu widget C++
// Store the widget reference and remove it when done
if (ActiveMenuWidget)
{
ActiveMenuWidget->RemoveFromParent();
ActiveMenuWidget = nullptr;
} See Also
Tags
Version History
Introduced in: 4.5
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
| 5.1 | stable | RemoveFromViewport deprecated; use RemoveFromParent. |
Feedback
Was this helpful?