How to change text in widget using c++

if (Name)
{
char* t1 = “text1”;
FText t2 = FText::FromString(ANSI_TO_TCHAR(t1));
Name->SetText(t2);
}
really not sure why you are doing that for?

 UPROPERTY(BlueprintReadOnly, meta = (BindWidget))
   class UTextBlock* NameTextBlock;

BindWidget is your friend here. Your textblock in UMG MUST be named “NameTextBlock”.

   if (NameTextBlock)
   {
       NameTextBlock->SetText(FText::FromString("Test Text"));
   }

like i said, not sure why you was doing char* t1 and then converting back then calling SetText. Seems a bit long winded.

1 Like