1

i have define a qvariant with metatype of QMetaType::QPolygon but im not able to retrieve the QPolygon from the QVariant.

QVariant is having toInt(), toLin(), toList() but not toPolygon(). but not any function call to convert it back to QPolygon .

Wagmare
  • 1,354
  • 1
  • 24
  • 58
  • 1
    Such a coincidence! Someone has just asked a similar question (but more general): http://stackoverflow.com/questions/24362946/how-can-i-cast-a-qvariant-to-custom-class – Tay2510 Jun 23 '14 at 10:35

1 Answers1

3

You can use the template method T QVariant::value() for that.

Example:

QPolygon poly = myVariant.value<QPolygon>();
epsilon
  • 2,849
  • 16
  • 23