Unsolved QPainter drawText ignores last blank space in a multiple line string
-
Hi guys,
We have a customized QGraphicsItem which paints itself. However, in below code:
QTextOption textOption; textOption.setWrapMode(QTextOption::WrapAnywhere); textOption.setAlignment(Qt::AlignRight); textOption.setFlags(QTextOption::IncludeTrailingSpaces); text = QString("Parameter \nSettings "); painter->drawText(rcText, text, textOption);
The blank space after 'Parameter' is always ignored, but the one after 'Settings' is not ignored.
User wants to get a little border when drawing the text. We know we can reduce the text rectangle to fulfill the request. But still want to know is there anyway to let Qt respect the blank space in first line? Tried many text options and flags but no one works.Thanks.
-
@wthung Maybe adding Qt::TextIncludeTrailingSpaces helps?
https://doc.qt.io/qt-5/qt.html#TextFlag-enum -
@wthung said in QPainter drawText ignores last blank space in a multiple line string:
QTextOption::IncludeTrailingSpaces
@jsulm Tried QTextOption::IncludeTrailingSpaces but not work. QTextOption::IncludeTrailingSpaces has the same defined value as Qt::TextIncludeTrailingSpaces, so I think it does not work as well?