I added a lot widgets into a verticalBox as child widgets. The verticalBox’s parent widget is a scrollbox. So it could get right position when I scroll the bar if the created widget is rendering in the scrollbar. But if not the position look like a cache position.
And this is the way I get the absolutePos with widgets.
if (Widget)
{
const FGeometry& Geometry = Widget->GetCachedGeometry();
FVector2D Pixel2D;
FVector2D Viewport2D;
USlateBlueprintLibrary::LocalToViewport(Widget, Geometry, LocalPos, Pixel2D, Viewport2D);
// PosX, PosY is the output position
PosX = Viewport2D.X;
PosY = Viewport2D.Y;
}