TextBlock's SetText() problem

I have a problem when I use TextBlock’s SetText function. I thought that the problem was somewhere in my project so I created TPS template. I created UserWidget and HUD classes in C++ and derived them in blueprints (and assigned them in gamemode class) but it still don’t update the text on the widget. Did I miss something? Is there something I don’t know about?
Screenshots:

C++

image

Blueprint:
image

image

I’m not in front of an editor to test, however, have you tried setting the text AFTER adding to the viewport? I’m wondering if the order of operations is messing you up. Potentially the call to OnInitialized is getting called during the AddToViewport, thus overwriting your SetText.

Also…is there a reason you’re not called the parent NativeOnInitialized (e.g. Super::NativeOnInitialized)?

  1. Yes I tried set text before and after AddToViewport, nothing changed. On the screenshot is just the latest “attempt”
  2. Well I really don’t know how things work under the hood but I assume that the OnInitialized function only called once when widget is created (CreateWidget(…)).
  3. Yeah my bad, I just forgеt to write Super::… regularly (and still nothing changed).

Also I think it worth mentioning that it also doesn’t work in blueprints. If I SetText in BP it also don’t change the text, So my guess is that there is a problem with binding (meta=bindwidegt).

Okay, I was messing around and find out that the problem was creating UTextBlock manually in c++.

Just to clarify to anyone who can come here later.

If you use meta = (BindWidget), you don’t have to create the object in code, just add an object of the same class with the same name in the blueprint.