1

I'm implementing the free-form style drawing for drawing a free path using the mouse press and move with Qpainter QPainterpath

Now i have to detect when exactly the drawn path crossed or intersects with the other. how i can identify when the lines crossed each other at some point and give warning to the user.

enter image description here

Nejat
  • 31,784
  • 12
  • 106
  • 138
Wagmare
  • 1,354
  • 1
  • 24
  • 58

1 Answers1

1

Qt API does not have this capability to tell that if a path composed of different elements intersect in a point or not. You should check it by your self. When the path is finished, compare piece-wise segments of the path using QPainterPath::​intersects function. The elements could be accessed via QPainterPath::​elementAt(int index).

Nejat
  • 31,784
  • 12
  • 106
  • 138
  • so i have to pass the same painter path as an argument ..? – Wagmare Feb 19 '15 at 13:26
  • No. That solution was for different paths. There is nothing in API to check intersection of a single path. You should do it on your own. See the updated answer. – Nejat Feb 19 '15 at 13:48
  • sorry to ask you about it late . QPainterPath::Element repPath = thePath.elementAt(i); returns element . then how i can check the points in it .. ? shall i use polygon instead of it ..? – Wagmare Feb 23 '15 at 06:29