Element text item group can now be framed.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5410 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-06-24 11:16:37 +00:00
parent deabf5f2ad
commit ea3b25fa75
7 changed files with 117 additions and 32 deletions

View File

@@ -184,6 +184,30 @@ Qt::Alignment DiagramTextItem::alignment() const
return m_alignment;
}
/**
* @brief DiagramTextItem::frameRect
* @return the rect used to draw a frame around this text
*/
QRectF DiagramTextItem::frameRect() const
{
//Get the bounding rectangle of the text
QSizeF size = document()->size();
size.setWidth(document()->idealWidth());
//Remove the margin. Size is exactly the bounding rect of the text
size.rheight() -= document()->documentMargin()*2;
size.rwidth() -= document()->documentMargin()*2;
//Add a little margin only for a better visual;
size.rheight() += 2;
size.rwidth() += 2;
//The pos of the rect
QPointF pos = boundingRect().center();
pos.rx() -= size.width()/2;
pos.ry() -= size.height()/2;
return QRectF(pos, size);
}
/**
* @brief DiagramTextItem::paint
* Draw this text field. This method draw the text by calling QGraphicsTextItem::paint.