Do the containers have size?

I’ve read that containers are same size as his contents, but I’ve testing in C++ and yes, I can get Control Widget size, like Button size, by CachedGeometry, but I cant get size of Container Widgets like HorizontalBox, though that box is containing two buttons.

Is there any way to get that size?
I need it to determine at runtime the position a container should occupy relative to an anchor (half its height and half its width), and set it. And it seems strange to me that information as basic as size is not already calculated. I guess so, but I don’t know where.

I could manually loop through the contents of my container and calculate the width, but I think I’d be missing information like margin, nudge and such.

You can get the Cached Geometry of a Wiegst with the GetCachedGeometry node.
From this, you should be able to get the width and height (f.e. desiredWidth desiredHeight).

be aware, that one prepass has to be finished, in order to get the sizee. You can add a delay before trying to get the cached Geometry… Or force a Prepass with ForcePrepass Node.

I have the solution. In the test I have done I have two buttons inside a horizontal box inside a canvas panel.
Well, the size is in the Slot in which the horizontal box is inserted, NOT in the widget.
And you have to cast the canvas panel slot to the correct type, since the generic slot panel doesn’t handle the concept of size.

So:

void UTestWidget::NativeConstruct()
{
	if (Button && Button_30)
	{
		FVector2D HorizontalBoxSize = Cast<UCanvasPanelSlot>(Button->GetParent()->Slot)->GetSize();
		UE_LOG(LogTemp, Warning, TEXT("HorizontalBoxSize: %s"), *HorizontalBoxSize.ToString());

	}
}

LogTemp: Warning: HorizontalBoxSize: X=100.000 Y=30.000

Although when you set “Size to content”, GetSize does not display the real size. GetDesiredSize is supposed to be used in this case, but I haven’t gotten it to work yet.

PD:
After thinking about it a lot I think that User Interfaces in general don’t like you to use absolute values. And that the solution to my specific case, to place an element in the center in relation to a point, is to use the Alignment, instead of entering a specific position value.