3

I am trying to check collisions between a QPolygon and a QRect by turning the QRect into a QPolygon. However, the rectangle might also have a rotation that I have added, so I am wondering how I would turn that QRect into a QPolygon taking into account the rotation?

Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
Tom Leese
  • 19,309
  • 12
  • 45
  • 70

1 Answers1

3

I think you can convert QRect into QPolygon using QMatrix::mapToPolygon.

Here is the description: http://doc.qt.io/qt-5/qmatrix.html#mapToPolygon

I believe you will be able to convert your QRect into QPolygon taking the rotation matrix into account.

Edit: Actually QTransform::mapToPolygon can be more suitable in this case. Please try:

http://doc.qt.io/qt-5/qtransform.html#mapToPolygon

as well.

Christophe Weis
  • 2,518
  • 4
  • 28
  • 32
Emir Akaydın
  • 5,708
  • 1
  • 29
  • 57