Setting the root node of a control through public variables is invalid.

I want the user component to obtain the user component that uses it, and I want to do it through editor settings. I have tried many methods, but they have not worked.
However, if I use getself to perform runtime assignment like a sub user control, then there is no problem.

in short,When using the editor, how can I make my custom widget aware of who is wrapping it? Or how can I obtain the slot of this custom control?

It seems that I have identified the problem. When other controls use the user control, such as this “dragbutton”,Self→getSlot() is ok, but CanvasPanel→getSlot() is none.

My English is not so good.So let me confirm this again: When user widget A wraps user widget B, the wrapped widget B cannot obtain the slots through its top-level widget . However, the self reference of B has slots.

I haven’t read the source code. I’m just guessing what might be the connection between the user widget and the top-level widget of the user widget ?

I have created a simpler example.

1 Like

Hi everyone,

I’m encountering the following error in Unreal Engine:

“Setting the root node of a control through public variables is invalid.”

I’d like some help understanding:

  1. What this error means — in which situations it appears.

  2. Why setting the root node via public variables is not allowed — what technical constraints or engine architecture cause this limitation.

  3. How to fix it or work around it — what the recommended practices are.

    • Should I use protected/private variables?

    • Should I set the root node dynamically in code or blueprint rather than via public variables?

    • Are there any documented guidelines/examples for doing this correctly?

Here’s what I’m currently doing:

  • I have a custom UserWidget / Control (or whatever UE control) with a root node member (e.g. a panel or canvas).

  • I marked this root node as public, intending to assign it in the editor or via Blueprint.

  • When I compile or run, I get the error above.

If anyone has encountered this before, or knows where in the source/docs this is explained, I’d appreciate your insight.

Thanks in advance!