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

**URL:** <https://forums.unrealengine.com/t/how-can-i-draw-lines-on-umg-by-c-code/407787>\
**Category:** UI\
**Tags:** draw, line, unreal-engine, question, CPP, UMG\
**Created:** [October 24, 2017, 5:41am UTC](https://forums.unrealengine.com/t/how-can-i-draw-lines-on-umg-by-c-code/407787 "2017-10-24T05:41:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_42835a05](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_42835a05](https://forums.unrealengine.com/u/anonymous_user_42835a05)\
**Post date:** [October 24, 2017, 5:41am UTC](https://forums.unrealengine.com/t/how-can-i-draw-lines-on-umg-by-c-code/407787/1 "2017-10-24T05:41:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Nachtmahr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nachtmahr](https://forums.unrealengine.com/u/Nachtmahr)\
**Post date:** [October 24, 2017, 5:57am UTC](https://forums.unrealengine.com/t/how-can-i-draw-lines-on-umg-by-c-code/407787/2 "2017-10-24T05:57:38Z")

</div>

Same way [UWidgetBlueprintLibrary::DrawLine | Unreal Engine Documentation](https://docs.unrealengine.com/latest/INT/API/Runtime/UMG/Blueprint/UWidgetBlueprintLibrary/DrawLine/index.html)

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

---

<div class="post-metadata">

**Author:** ![Nachtmahr](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nachtmahr](https://forums.unrealengine.com/u/Nachtmahr)\
**Post date:** [October 24, 2017, 6:09am UTC](https://forums.unrealengine.com/t/how-can-i-draw-lines-on-umg-by-c-code/407787/3 "2017-10-24T06:09:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Chwindor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chwindor](https://forums.unrealengine.com/u/Chwindor)\
**Post date:** [October 24, 2017, 6:14am UTC](https://forums.unrealengine.com/t/how-can-i-draw-lines-on-umg-by-c-code/407787/4 "2017-10-24T06:14:35Z")

</div>

You are right, sorry for miss understanding:)

---

<div class="post-metadata">

**Author:** ![SuryaPrakashModi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SuryaPrakashModi](https://forums.unrealengine.com/u/SuryaPrakashModi)\
**Post date:** [May 25, 2021, 7:21am UTC](https://forums.unrealengine.com/t/how-can-i-draw-lines-on-umg-by-c-code/407787/5 "2021-05-25T07:21:35Z")

</div>

watch this. [How To Do Line Tracing Using C++ In Unreal Engine - YouTube](https://youtu.be/LWeQicz_teo)

---

<div class="post-metadata">

**Author:** ![Killerpie95](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Killerpie95](https://forums.unrealengine.com/u/Killerpie95)\
**Post date:** [October 26, 2022, 11:24pm UTC](https://forums.unrealengine.com/t/how-can-i-draw-lines-on-umg-by-c-code/407787/6 "2022-10-26T23:24:53Z")

</div>

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(),
