Create Widget and display it pure c++

So what I do if your class inherits from UUserWidget if this. I create a function in the class that will create the widget that use the tag BlueprintImplementableEvent. This, allows me to call this function from the C++ class but define it in blueprints. The definition in blueprint is the traditional node Create Widget, where you can use a Widget Blueprint.


#pragma once

#include "CoreMinimal.h"
#include "Components/BaseComponent.h"
#include "Login.generated.h"

class UBackgroundBlur;

 */
UCLASS()
class UIMODULE_API UYourWidget: public UUserWidget
{
	GENERATED_BODY()

public:

	UPROPERTY(BlueprintReadOnly, meta = (BindWidget))
	UBackgroundBlur* B_Background;


	UFUNCTION(BlueprintImplementableEvent, Category = "Config|Implementable")
	void CreateWidget();

	
};

Once the widget is created using the BlueprintImplementableEvent, I save it as variable in my class to do what i want to do like this for example.

CreateWidget();

if (WidgetBlueprintVariable)
{
	WidgetBlueprintVariable->AddToViewport();
	...
}