Binding a UUserWidget C++ Property to Widget blueprint subwidget?

If I have a C++ property of a user widget that’s itself a widget - for example:

UCLASS()
class UMyWidget : public UUserWidget {
    /*...*/

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    UButton* Button;

    /*...*/
};

and I create a Blueprint dervied from UMyWidget called BP_MyWidget, and in BP_MyWidget I add and position a UButton in the UMG Editor, is there a way to have the Button property assigned to this UButton ?

(At the moment I make it a variable in the blueprint called ButtonImpl and then in the construct method I assign ButtonImpl to Button, but is there a way to bind it directly? It’s a lot of boilerplate for non-trivial panels.)

You mean like this?

UPROPERTY(meta = (BindWidget))
UButton* Button;
2 Likes

Yeah exactly like that, thanks! I searched for “widget” in Unreal Engine UProperty Specifiers | Unreal Engine 5.0 Documentation but BindWidget is not listed there. I guess it must be documented elsewhere.

Looks like they’re listed here at least:

2 Likes