How to declare an array of custom sub-widgets?

I’m trying to create an inventory system, the Inventory widget has an array of Item sub-widgets which i want to declare on UMG Designer. But when i declare them and then compile, it turns them back to blank.

InventoryWidget.h

UInventorySubWidget : public UUserWidget
{
	GENERATED_BODY()

protected:
	UInventorySubWidget(const FObjectInitializer& ObjectInitializer);

	virtual void NativeConstruct() override;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(BindWidget))
	TArray<class UItemSubWidget *> Items;
};

Before Compile:

After Compile:

Hi, in this case you have an array of null pointers. You need to use
TArray<TSubclassOf<class UItemSubWidget>> Items;

1 Like

@real.dude I thought about that, but wouldn’t this give me a UClass of the ItemSubWidget? I want an array of pointers which will be filled on the UI Designer. The only way I found to solve this untill now is to create every pointer variable for the corresponding sub-widget which is not practical…