# Can't AddDynamic to DYNAMIC\_MULTICAST\_DELEGATE in C++

**URL:** <https://forums.unrealengine.com/t/cant-adddynamic-to-dynamic-multicast-delegate-in-c/1222218>\
**Category:** C++\
**Tags:** unreal-engine, delegates\
**Created:** [July 7, 2023, 11:30am UTC](https://forums.unrealengine.com/t/cant-adddynamic-to-dynamic-multicast-delegate-in-c/1222218 "2023-07-07T11:30:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bogdanspbm](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bogdanspbm/32/726230_2.png) [@bogdanspbm](https://forums.unrealengine.com/u/bogdanspbm)\
**Post date:** [July 7, 2023, 11:30am UTC](https://forums.unrealengine.com/t/cant-adddynamic-to-dynamic-multicast-delegate-in-c/1222218/1 "2023-07-07T11:30:01Z")

</div>

Can’t bind to DECLARE\_DYNAMIC\_MULTICAST\_DELEGATE\_OneParam. What can be a problem?

My code:

```auto
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSlotUpdateSignature, int, SlotIndex);

UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class INVENTORYPLUGIN_API UInventoryComponent : public UActorComponent
{
	GENERATED_BODY()

public:
	UInventoryComponent();
	void AddItem(AItem* Item);
	
	UPROPERTY(BlueprintAssignable, Category = "Listeners")
	FOnSlotUpdateSignature OnSlotUpdateDelegate;
};

```

From UInventoryComponent I can AddDynamic and Broadcast. But next I have Slot UUserWidget:

```auto
UCLASS(Blueprintable, BlueprintType)
class INVENTORYPLUGIN_API UInventorySlot : public UUserWidget
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintCallable, Category = "Inventory")
	void Update();

	virtual void NativeConstruct() override;
	
	UFUNCTION()
	void OnSlotUpdate(int UpdatedSlotIndex);
};

```

In implementation I can’t do addDynamic:

```auto
void UInventorySlot::NativeConstruct()
{
	Super::NativeConstruct();

	const UInventoryComponent* Inventory = GetInventory();

	if (!Inventory)
	{
		return;
	}

	Inventory->OnSlotUpdateDelegate.AddDynamic(this, &UInventorySlot::OnSlotUpdate);
}

```

 ![1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/6/1063487e1faf8caf94ae1c10c0e3fc15e0c69f80.jpeg)

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [July 7, 2023, 12:09pm UTC](https://forums.unrealengine.com/t/cant-adddynamic-to-dynamic-multicast-delegate-in-c/1222218/2 "2023-07-07T12:09:01Z")

</div>

Few things that might be it,

The Inventory = const, try removing const.  
Delegate is using int. So far I have only used int32 as this is supported by blueprint. Unsure how far int64 support goes with it these days.

---

<div class="post-metadata">

**Author:** ![bogdanspbm](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bogdanspbm/32/726230_2.png) [@bogdanspbm](https://forums.unrealengine.com/u/bogdanspbm)\
**Post date:** [July 7, 2023, 1:46pm UTC](https://forums.unrealengine.com/t/cant-adddynamic-to-dynamic-multicast-delegate-in-c/1222218/3 "2023-07-07T13:46:23Z")

</div>

Replacing **const** helped me. Thank you.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [July 7, 2023, 2:23pm UTC](https://forums.unrealengine.com/t/cant-adddynamic-to-dynamic-multicast-delegate-in-c/1222218/4 "2023-07-07T14:23:20Z")

</div>

Nice 🙂 . Something else not related to your original problem, but you should really make delegate bindings on a widget during OnInitialized. this is because events like Construct and PreConstruct can run multiple time, while OnInitialized runs once.

> [UUserWidget::Construct | Unreal Engine Documentation](https://docs.unrealengine.com/4.26/en-US/API/Runtime/UMG/Blueprint/UUserWidget/Construct/)

Construct is called every time when you move the widget in the widget hierarchy or remove and re add a widget to the viewport I think.
