PDA

View Full Version : Draw angle indicator QPainter



iPick12
26th October 2012, 11:08
Hello, I'm trying to draw and angle indicator using QPainter like the following pic
8356
I know that the only way to do this is drawArc() but I can't seem to find the proper arguments.
I have the screen coordinates of the corner center, and of the two endpoints.

Thanks in advance

wysota
26th October 2012, 14:27
You need to use trygonometry to calculate the angles and bounding rectangle of the circle the arc is part of. There is an upright triangle consisting of the corner point, lower end point and its projection onto the horizontal axis. From that you can calculate the length of the projection line and the starting angle. Similar for the other endpoint and the vertical axis -- this will give you the span angle. The bounding rect is then easy to calculate using the two projected lines.