Creating a Widget in just C++

There is a way to have your entire widget logic in C++ and only use BP for its design.

Make a C++ class which derives from UUserWidget, simply UserWidget in the create a class selector.
Make a new BP widget and in the class settings make it use your custom class as its parent.

You can create the widget with the way Cd1232 mentioned and then make a variable for each type that you need to have logic for (Text Blocks, Scroll Boxes etc) and use the UPROPERTY() specifier meta = (BindWidget) to bind the visual element that you want to handle in C++.

To bind certain delegates for your variables like Click events for buttons, you need to override the initialize method:

bool Initialize() override;

and in there bind your delegates like so:

bool UYourClass::Initialize()
{
    bool Success = Super::Initialize();
    	if (!Success) { return false; }
    
    	if (YourCustomButtonCreatedInHeader)
    	{
    		YourCustomButtonCreatedInHeader->OnClicked.AddDynamic(this, &UYourClass::OnClickedCustomButton);
    	}
    	return true;
}

And then have the on clicked logic on your custom OnClickedCustomButton() function.

Making the graphics in C++ is the old way of making UI which I strongly advise against as it is a lot of extra work for nothing.