76 QFontMetrics font_metrics(
m_font);
77 double height = font_metrics.height()/2;
79 for (
auto line:
m_text.split(
"\n")) {
80 height += font_metrics.height();
81 QRectF font_rect = font_metrics.boundingRect(line);
82 if (font_rect.width() > width) {
83 width = font_rect.width();
86 width += font_metrics.averageCharWidth()*2;
88 return QRectF(0, 0, width, height);
93 const QStyleOptionGraphicsItem* ,
98 painter->setFont (
m_font );
99 painter->setBrush (brush);
101 painter->setPen ( pen );
103 painter->drawRect ( rect );
104 painter->drawText(rect.adjusted(5,5,-2,-2), Qt::AlignJustify,
m_text);