PDA

View Full Version : Printing white spaces in QPlainTextEdit- the QtCreator way



elcuco
14th January 2010, 21:01
Hi all, I am trying to understand what's the way to print white spaces inside a QPlainTextEdit (or QTextEdit...) and I am looking for advices - what's the best way to do this?

Can anyone find how/where it's done in QtCreator?

elcuco
15th January 2010, 20:11
QTextOption option = document()->defaultTextOption();
if (on)
option.setFlags(option.flags() | QTextOption::ShowTabsAndSpaces);
else
option.setFlags(option.flags() & ~QTextOption::ShowTabsAndSpaces);
option.setFlags(option.flags() | QTextOption::AddSpaceForLineAndParagraphSeparators );
document()->setDefaultTextOption(option);


It seems this functionality has been moved down to QTextDocument:
http://qt.nokia.com/doc/4.6/qtextoption.html#Flag-enum