hi friends,
i am having a QGraphicsTextItem and QGraphicsItem where the user can give input text to the text item using setTextInteractionFlags.
now i wanted to draw the same text on the QGraphicsItem paint function .
so i passed the text item "text", "font" and the "boundingRect" to the QGraphicsItem paint event
TEXT = "theCurrentText"
FONT = "theCurrentFontSize"
boundingRect = m_bounds;
and painted as
QFont segoeFont
("Segoe Regular");
segoeFont.setPointSizeF(theCurrentFontSize );
p->setFont(segoeFont);
p->setPen(actPen);
QRectF bounds
= fma.
boundingRect(QRectF(0,
0, m_bounds.
width() ,
0), Qt
::TextWordWrap, theCurrentText
);
p->fillRect(bounds, Qt::white);
p->drawText(bounds, Qt::TextWordWrap, theCurrentText);
QFont segoeFont("Segoe Regular");
segoeFont.setPointSizeF(theCurrentFontSize );
p->setFont(segoeFont);
p->setPen(actPen);
QFontMetricsF fma( p->font());
QRectF bounds = fma.boundingRect(QRectF(0, 0, m_bounds.width() , 0), Qt::TextWordWrap, theCurrentText);
p->fillRect(bounds, Qt::white);
p->drawText(bounds, Qt::TextWordWrap, theCurrentText);
To copy to clipboard, switch view to plain text mode
but the text is not getting wrapped at any point . even hundreds of word i have given but still the words are getting cropped but showing in a single line.
my graphicstextitem
InitialGraphicsItem.jpg
and my graphicsitem
finalEyGsText(UgObject).jpg
i checked the debug statements of the the graphicstext item and graphicsitem .
The Ey Text item bounding rect value is: QRectF(-2,-2 1909.22x62)
The Ey text item font size value coming is: 8.25
The Ey Text bounding rect value is: QRectF(0,0 1909x86)
The Ey font size value coming is: 8.25
both bounding rect and font size are coming similar and both are child of same graphicsitem ..
please help me ..
Bookmarks