How can I Draw lines on UMG by C++ code?

I want to draw lines on a UMG canvas widget.I know there is a blueprint function called DrawLine can do this,but how to do this by C++ code?

Same way UWidgetBlueprintLibrary::DrawLine | Unreal Engine Documentation

You can get the Context by overriding the OnPaint Function as example.

1 Like

I don´t think he asked for Debug lines ^^ but yes that one exist too. AHud has also a Line Draw function.

You are right, sorry for miss understanding:)

watch this. How To Do Line Tracing Using C++ In Unreal Engine - YouTube

I include this library in my .CPP file and the only things that appear are DrawBox, DrawArc, and DrawCircle. I for the life of me cannot get DrawLine to appear as an option. I am trying to use it in NativePaint(),