# Spawning of an Actor with a WidgetComponent in C++

**URL:** <https://forums.unrealengine.com/t/spawning-of-an-actor-with-a-widgetcomponent-in-c/485894>\
**Category:** UI\
**Tags:** spawning, unreal-engine, Widget, CPP, question\
**Created:** [July 7, 2021, 5:27pm UTC](https://forums.unrealengine.com/t/spawning-of-an-actor-with-a-widgetcomponent-in-c/485894 "2021-07-07T17:27:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![banished\_angel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/banished_angel/32/625614_2.png) [@banished\_angel](https://forums.unrealengine.com/u/banished_angel)\
**Post date:** [July 7, 2021, 5:27pm UTC](https://forums.unrealengine.com/t/spawning-of-an-actor-with-a-widgetcomponent-in-c/485894/1 "2021-07-07T17:27:12Z")

</div>

Hello,

I have an Actor that contains a WidgetComponent that contains a UserWidget. If I spawn in C++ at runtime my Actor’s class, the WidgetComponent is invisible and the UserWidget is NULL. If I create a blueprint class from my Actor’s class and spawn it, everything is OK. Is it an expected behavior of Unreal Engine? If not, I’ll send the code to show. Thank you for your answers.

Best regards,  
Alexander Temnyakov

---

<div class="post-metadata">

**Author:** ![Sudo-Kid](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sudo-Kid](https://forums.unrealengine.com/u/Sudo-Kid)\
**Post date:** [July 8, 2021, 5:35pm UTC](https://forums.unrealengine.com/t/spawning-of-an-actor-with-a-widgetcomponent-in-c/485894/2 "2021-07-08T17:35:58Z")

</div>

You should always start by posting the code, it makes life easier for the person answering the question. It’s very possible to have a WidgetComponent or really any kind of object created at the C++ level when the Actor is created.
