how to override UUserWidget OnPaint

How do i override this function?

it seems so simple in blueprints.

What ive tried-
void OnPaint(UPARAM(ref) FPaintContext& Context) override;

void OnPaint(FPaintContext& Context) override;

You don’t override OnPaint, you override NativePaint. See the UPROPERTY specifier called BlueprintImplementableEvent? That means this is a Blueprint-only function that cannot be implemented in C++. NativePaint is the C++ equivalent.

In general with UE source code, when you see a function DoStuff that’s a BlueprintImplementableEvent, you’ll likely find another function called NativeDoStuff which is the C++ equivalent. If DoStuff is a BlueprintNativeEvent, the C++ equivalent is called DoStuff_Implementation.

4 Likes

Only just seen this now, figured this out eventually, Thanks! hopefully will help someone else.

Could you show what worked for you with nativepaint(). I’m having difficulty overriding it
image
[1/2] Compile CRHFMS.cpp
C:\Users\mcalister\Documents\Unreal Projects\FlightVisionProject 5.0\Source\FlightVisionProject\CRHFMS.h(77): error C3668: ‘UCRHFMS::OnPaint’: method with override specifier ‘override’ did not override any base class methods
[2/2] Compile CRHFMS.gen.cpp
C:\Users\mcalister\Documents\Unreal Projects\FlightVisionProject 5.0\Source\FlightVisionProject\CRHFMS.h(77): error C3668: ‘UCRHFMS::OnPaint’: method with override specifier ‘override’ did not override any base class methods

What does the class using it inherit from? double check the parent has nativepaint.

Your errors come from ‘UCRHFMS::OnPaint’, not from the NativePaint override.

I found my mistake: I just had the declaration in the header and no corresponding definition in the cpp. Silly me. Thank you!