Can't convert X to X?

Basically this error:

cannot convert argument 1 from 'TOptional< FSlateRenderTransform> ’ to 'TOptional< FSlateRenderTransform> ’

I’m using this function as a delegate in slate:

TOptional<FSlateRenderTransform> SSwatterMenuWidget::TransformTrump()
{
	FQuat2D Quat(FMath::DegreesToRadians(TrumpAngle));
	return TransformCast<FSlateRenderTransform>(Quat);
}

Which is being used in slate with this line:

.RenderTransform_Static(&SSwatterMenuWidget::TransformTrump)

So yea, kinda weird.

What is the type of RenderTransform_Static ? Can you post the declaration?

Is SSwatterMenuWidget::TransformTrump declared static?

I’m guessing not since it seems to be using the member variable TrumpAngle. In that case it won’t work with the RenderTransform_Static variant of Slate attributes, and you’ll probably want to use RenderTransform(this, &SSwatterMenuWidget::TransformTrump) instead.

Ah, I didn’t even think about that, thought static was referring to something else. It’s still not quite working though, RenderTransform seems to want an actual value instead of a delegate?

Using expression:

.RenderTransform(this,
&SSwatterMenuWidget::TransformTrump)

cannot convert argument 2 from ‘TOptional< FSlateRenderTransform> (__cdecl SSwatterMenuWidget::* )(void)’ to 'TOptional< FSlateRenderTransform> ’

This is all I have for my slate initialization:

    SLATE_BEGIN_ARGS(SSwatterMenuWidget)
    {}
    SLATE_ARGUMENT(TWeakObjectPtr<class ASwatterMenuHUD>, MainMenuHUD)
    SLATE_END_ARGS()

What widget are you calling RenderTransform on? Is it one of ours, or one you made yourself?

It seems from the error that RenderTransform is declared as a SLATE_ARGUMENT rather than a SLATE_ATTRIBUTE. Arguments can only accept values, not delegates.

Okay, I’ve just checked and RenderTransform is actually part of our common set of arguments for widgets (see TSlateBaseNamedArgs in DeclarativeSyntaxSupport.h).

SLATE_ATTRIBUTE( TOptional, RenderTransform )

This appears to be done to allow invalidation caching to function optimally, and you’re going to need to use the SWidget::SetRenderTransform function to update your render transform when it needs to change.

SetRenderTransform worked, thank you!