How can i set mouse cursor visible/hide by c++?

Hi i’m learning c++ and i’m curios to know - how can i set cursor by my widget visibility.

I have function that toggle widget visibility.

I want to add here showmouse cursor and set ui input only.

When the widget is not visible - set it visible, show cursor and set ui input. Else - hide widget and cursor and set input game only.

Help me please.

You need to get hold of the player controller first and then show mouse cursor:

APlayerController* PlayerControllerRef = UGameplayStatics::GetPlayerController(GetWorld(), 0);
PlayerControllerRef->SetShowMouseCursor(true);

Of course, you need to make respective includes:

#include "Kismet/GameplayStatics.h"
#include "GameFramework/PlayerController.h"