# how can i expose variable to create widget

**URL:** <https://forums.unrealengine.com/t/how-can-i-expose-variable-to-create-widget/883039>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question, Blueprint\
**Created:** [April 10, 2023, 10:32am UTC](https://forums.unrealengine.com/t/how-can-i-expose-variable-to-create-widget/883039 "2023-04-10T10:32:58Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![High500](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/high500/32/906557_2.png) [@High500](https://forums.unrealengine.com/u/High500)\
**Post date:** [April 10, 2023, 1:10pm UTC](https://forums.unrealengine.com/t/how-can-i-expose-variable-to-create-widget/883039/4 "2023-04-10T13:10:57Z")

</div>

hmm have a look at what this guy says

> [@How do i set values to exposed variables using CreateWidget in c++?](https://forums.unrealengine.com/t/how-do-i-set-values-to-exposed-variables-using-createwidget-in-c/340706/3):
>
> “Exposed on Spawn” is only relevant in BP. In C you would set the values as you would any other property. If they’re public, you can just set them. If they’re private you can use a Setter method. UMyWidgetClass\* MyNewWidget = T\<UMyWidgetClass\>CreateWidget(Owner, MyWidgetClassPtr); if (MyNewWidget) { //set public variable MyNewWidget-\>MyPublicFloat = 1.0f; //set private variable using setter method defined in your widget class MyNewWidget-\>SetMyPrivateFloat(5.0f); }

im guessing as soon as you create the widget you set its variables from that object

---

_[View the full topic](https://forums.unrealengine.com/t/how-can-i-expose-variable-to-create-widget/883039)._
