c++ Widget ExposeOnSpawn Property

Is there an equivalent to the the [SpawnActorDeferred][1] for UserWidgets? In Blueprints there is the following, which makes me think that there is some way, but i have been unable to find any documentation or functions to do so.

301465-exposedonspawncreatewidget.png

I’ve found some old questions that suggest that it wasn’t possible as of 2015.

The basic idea is so I can set some variables at creation time and work with them in the Native(Pre)Construct functions, like i would in a widget blueprint. My reference to Actors is that they have the SpawnActorDeferred and FinishSpawningActor, which allows c++ to have a time to initialize anything before the constructor is called.

If you are referring to Pre-construct, you just need to override it (same as in Blueprints).

(just to add, it’s the UUserWidget::NativePreConstruct that needs to be overriden)

What exactly are you trying to defer? Widgets are UObjects, not AActors. They don’t have a concept of spawning, they are created internally with NewObject.

Are you sure that the result of this node is already constructed? If I remember correctly, construction only happens when you add the widget to the screen or to another parent widget.

Thank you, you are correct. I had setup a test to figure out if the NativeConstruct was called as soon as the CreateWidget was called or after it at some point, but I had a flaw in my test which flipped how the results were represented. Hence the question, and your answer clarified why my test was incorrect.