Open sgbzona opened 7 years ago
basically you get back the rect of the handles, I implemented the line this way for now but its not the best but its a progress for now.
virtual void operator()(QGraphicsItem *item, const QRectF &rect)
{
auto lineItem =
dynamic_cast<LineAnnotationGraphicsItem*>(item);
if (lineItem)
{
const auto lineAngle = QLineF(lineItem->line()).angle();
if (lineAngle >= 0 && lineAngle <= 90)
{
lineItem->setLine(QLine(rect.bottomLeft().toPoint(), rect.topRight().toPoint()));
}
else if (lineAngle >= 91 && lineAngle <= 180)
{
lineItem->setLine(QLine(rect.bottomRight().toPoint(), rect.topLeft().toPoint()));
}
else if (lineAngle >= 181 && lineAngle <= 270)
{
lineItem->setLine(QLine(rect.topRight().toPoint(), rect.bottomLeft().toPoint()));
}
else
{
lineItem->setLine(QLine(rect.topLeft().toPoint(), rect.bottomRight().toPoint()));
}
}
}
I need to resize QGraphicsTextItem. It has only setTextWidth(), which changes only the width. No explicit function to set bounding rectangle. On resize using left resize handler, I need QGraphicsTextItem to move to new position. How to do that ?
class TextResizer : public SizeGripItem::Resizer { public: virtual void operator()(QGraphicsItem item, const QRectF& rect) { QGraphicsTextItem textItem = dynamic_cast<QGraphicsTextItem*>(item);
if (textItem)
{
textItem->setTextWidth(rect.width());
}
}
};
Hi, I'm trying to add other shapes (Polygon, Line, etc) but when it is created the resizer:
Or maybe, do I need to add something else?