This widget is meant to be put in a scroll box. I gather the informations needed to construct this widget from a datatable and then add it as a child to the scrollbox. Here is the script that I have made.
I have changed my manner of doing this, I’ve moved the loading process into c++. It is still a little messy but at least it works. I post my solution here, it may help other people.
I have created a class which derives from UUserWidget.
// Pre-declaration
class UImage;
class UTextBlock;
class UDataTable;
/**
*
*/
UCLASS()
class MYPROJECT3_API UImageWidget : public UUserWidget
{
GENERATED_BODY()
public:
// This function assumes that the datatable is based on FSubjectDataTableRow structure
UFUNCTION(BlueprintCallable, Category = "Custom")
void ConstructFromDataTable(UDataTable * DataTable, FName RowName);
private:
// The icon
UPROPERTY(meta = (BindWidget))
UImage * Icon;
// The label
UPROPERTY(meta = (BindWidget))
UTextBlock * Label;
};
The meta tag “BindWidget” permits to access certain parts of the widget, the names must correspond with the names in the UMG widget.
The data table is created upon a structure that I’ve made in C++. I put it here as well.