How do you rebuild the whole UI after calling InsertChildAt?

Documentation of InsertChildAt says:

This does not update the live slate version, it requires a rebuild of the whole UI to see a change.

How do you “rebuild the whole UI”?

I tried RebuildWidget, SynchronizeProperties on “this”, the UPanelWidget and all the Slots. But it did not update.

Try taking a look at ForceLayoutPrepass(); and InvalidateLayoutAndVolatility() in the Widget.h.

I know Invalidate essentially flags it for redraw on next frame, and affects itself and children. I have not used the force prepass, but the description sounded promising for what you need.

For anyone finding this for the purpose of rebuilding the whole widget after a property change, if e.g. the underlying slate widget does not expose the parameters via a setter, but only with a Slate-Parameter in the constructor:

Use
UPROPERTY([...], meta=(DesignerRebuild="True")) bool MyParameter;
in the declaration of the property and on every change of that property a rebuild of the widget is issued.

(Tested in 4.26.2)

1 Like

This doesn’t seem to work for me. I’m using InsertChildAt but the widgets seem to be keeping the order they were created in. I’ve done some debugging and the indexes are being changed, but this does not actually move the widget to that index.

Hello @Primus Halal,
My answer does actually not apply to the thread author’s question. I just posted this “non matching” answer here, since it solve a somewhat similar problem and everyone with that problem will find this thread eventually. So sorry, if I made some hope for somebody here…

you can do like this:
ScrollRoot1->ClearChildren();
ScrollRoot1->AddChild(item);