diff --git a/sources/qetgraphicsitem/commentitem.cpp b/sources/qetgraphicsitem/commentitem.cpp index 85e43b8a1..59985b6a9 100644 --- a/sources/qetgraphicsitem/commentitem.cpp +++ b/sources/qetgraphicsitem/commentitem.cpp @@ -105,13 +105,14 @@ bool CommentItem::setTextParent() { * update the content of this item * (draw this item in a QPicture) */ -void CommentItem::updateLabel() { +void CommentItem::updateLabel() +{ QString comment = m_element -> elementInformations()["comment"].toString(); if (comment == m_comment && !m_text_parent) return; - if (comment != m_comment) { - + if (comment != m_comment) + { m_comment = comment; QPen pen(Qt::black); @@ -121,10 +122,9 @@ void CommentItem::updateLabel() { painter.setPen (pen); painter.setFont (QETApp::diagramTextsFont(6)); - QRectF drawing_rect(QPointF(0,0), QSizeF(70, 100)); - QRectF text_bounding; + QRectF text_bounding = painter.boundingRect(QRectF(QPointF(0,0), QSizeF(70, 1)), Qt::TextWordWrap | Qt::AlignHCenter, m_comment); - painter.drawText(drawing_rect, Qt::TextWordWrap | Qt::AlignHCenter, m_comment, &text_bounding); + painter.drawText(text_bounding, Qt::TextWordWrap | Qt::AlignHCenter, m_comment); text_bounding.adjust(-1,0,1,0); //adjust only for better visual painter.drawRoundedRect(text_bounding, 2, 2); diff --git a/sources/qetgraphicsitem/crossrefitem.cpp b/sources/qetgraphicsitem/crossrefitem.cpp index 59fe6a928..638ebd34b 100644 --- a/sources/qetgraphicsitem/crossrefitem.cpp +++ b/sources/qetgraphicsitem/crossrefitem.cpp @@ -523,19 +523,22 @@ void CrossRefItem::fillCrossRef(QPainter &painter) { * Add the comment info of the parent item if needed. * @param painter painter to use for draw the text */ -void CrossRefItem::AddExtraInfo(QPainter &painter) { +void CrossRefItem::AddExtraInfo(QPainter &painter) +{ QString comment = m_element -> elementInformations()["comment"].toString(); bool must_show = m_element -> elementInformations().keyMustShow("comment"); - if (!comment.isEmpty() && must_show) { + if (!comment.isEmpty() && must_show) + { painter.save(); painter.setFont(QETApp::diagramTextsFont(6)); QRectF r, text_bounding; qreal center = boundingRect().center().x(); r = QRectF(QPointF(center - 35, boundingRect().bottom()), - QPointF(center + 35, boundingRect().bottom() + 50)); - painter.drawText(r, Qt::TextWordWrap | Qt::AlignHCenter, comment, &text_bounding); + QPointF(center + 35, boundingRect().bottom() + 1)); + text_bounding = painter.boundingRect(r, Qt::TextWordWrap | Qt::AlignHCenter, comment); + painter.drawText(text_bounding, Qt::TextWordWrap | Qt::AlignHCenter, comment); text_bounding.adjust(-1,0,1,0); //adjust only for better visual