Thank you so much. I now completely see what you meant, I'm sorry for not understanding it the first time :D working with Qt for just about 4 months now. I implemented your idea and it works just as I wanted it to. Really appreciate your help and willingness to explain your solution.
If anybody stumbles on this issue too here is the working polygon resizer class:
class PolygonResizer : public SizeGripItem::Resizer // resize class for polygon
{
public:
{
dynamic_cast<QGraphicsPolygonItem*>(item);
QRectF itemBoundingRect
= item
->boundingRect
();
float sx = float( rect.width() ) / float( itemBoundingRect.width() );
float sy = float( rect.height() ) / float( itemBoundingRect.height() );
QTransform transform;
transform.scale( sx, sy );
QPolygonF oldPolygon
= polygonItem
->polygon
();
QPolygonF newPolygon
= oldPolygon
* transform;
if (polygonItem)
{
polygonItem->setPolygon( newPolygon );
}
}
};
class PolygonResizer : public SizeGripItem::Resizer // resize class for polygon
{
public:
virtual void operator()(QGraphicsItem* item, const QRectF& rect)
{
QGraphicsPolygonItem* polygonItem =
dynamic_cast<QGraphicsPolygonItem*>(item);
QRectF itemBoundingRect = item->boundingRect();
float sx = float( rect.width() ) / float( itemBoundingRect.width() );
float sy = float( rect.height() ) / float( itemBoundingRect.height() );
QTransform transform;
transform.scale( sx, sy );
QPolygonF oldPolygon = polygonItem->polygon();
QPolygonF newPolygon = oldPolygon * transform;
if (polygonItem)
{
polygonItem->setPolygon( newPolygon );
}
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks