I don't understand ChildSlot[...]

This is “hack” in C++ using operator overloads which allows to modify behavior of operators, also add support of operators to structs and classes (that why you can use them with FVector or FRotator for example even thru they are custom structs inside UE4).

http://en.cppreference.com/w/cpp/language/operators

Slate using it to create this nice looking layout definition syntax that looks nice in C++, because using function or setting varbales would be annoying to write entire layout in, the final result of it is constructed widget class based on that layout data. so + SOverlay::Slot() is just + operator overload of slot builder which adds slots together (SOverlay::Slot() + SOverlay::Slot() that what really happening here). the array brackets “[]” are operator too, this allows to make custom array system (in fact UE4 got it’s own array implementations TArray, TMap, TSet etc.), slate use this to contain layout definition of widgets inside the slot Slot

It’s kind of more fancy looking chained builder pattern if you ever seen those in C++

http://www.spuriousthoughts.com/2012/11/06/chaining-setters-in-c-builder-pattern/

So yes, even thru Slate do those twists here it is still 100% valid C++ syntax and any today compiler by standard should deal with it without any issue.

The tabulation might be what confusing you, remember that in most languages “new lines”, tabs and spaces (outside quotes) are ignored, you can hit enter after every space all the time, compiler will still compiler it normally as it process everything as single stream of characters. it actually prime reason why you need to place “;” after everything and yes you can place everything in single line (except preprocessor instruction like #include), compiler have 0 issue with that. This is something you wont see in UE4, but for example some C/C++ projects place enter and tabs on each argument of a function definition so it is not cut by text editor and all of them are visible all at once, compiler will process that normally without any issue. It is recmanded to do new lines and tabs like that so Slate layout information is more readable to programmers

1 Like

So, I am using Slate a bit and it works, but I really don’t understand it.
Here is working code:

	ChildSlot
		[
			SNew(SOverlay)
			+ SOverlay::Slot()
		.HAlign(HAlign_Center)
		.VAlign(VAlign_Top)
		[
			SNew(STextBlock)
		.Text(FText::FromString("Main Menu"))
		]


	+ SOverlay::Slot()
		.HAlign(HAlign_Center)
		.VAlign(VAlign_Center)
		[
			createMenu()
		]
		];

It does what I want.
But, what is happening here, C++ wise?
Childslot is a member of type FSimpleSlot.

I use that member, behind I do what? I start an array with ‘[’? Or is that some kind of initialization?
What is the +Overlay doing?

I understand what is happending, I think.

I do not understand why it is happening. I have problems with the C++ here.
I think the answer could be something very basic, which i just don’t get yet.

Oh my god. Operators. I never thought about these here.
Thanks a lot man!