Try this:
title = LOCTEXT(“1”, *t);
Try this:
title = LOCTEXT(“1”, *t);
I have an FText variable called title
that I need to display to the user. I’m trying to set it via a function:
void ALocation::SetTitle(FString t) { // what datatype do I use here?
title = LOCTEXT("1", t);
}
It’s just I’m not sure how to pass a string literal as a parameter so that LOCTEXT will accept it.
Didn’t work. Somehow I’m getting: error C2065: 'L' : undeclared identifier
I have no variable named L
.
If that is the error you get then LOCTEXT probably requires an ANSI style string of chars. I think FString uses TCHAR internally. You will need to convert your TCHAR string to a char string and then pass it.
I was thinking about this all wrong. First of all, I changed the function to use FText:
void ALocation::SetTitle(FText t) {
title = t;
}
Then, in the class that calls the function, that is where I put the #define LOCTEXT_NAMESPACE "foo"
and set the FText:
#define LOCTEXT_NAMESPACE "foo"
...
location1->SetTitle(LOCTEXT("Title", "Title"));
...
#undef LOCTEXT_NAMESPACE