[Qt-interest] QTextEdit: Tab spacing

Stephan Rose kermos at somrek.net
Tue Jun 2 17:42:01 CEST 2009


Having a problem with setting the tab spacing I want in QTextEdit.

The font it is using is a monospace font and I need to set my tab spacing so that 1 tab = 4 spaces. I've verified that the font is behaving as it should by actually putting in 4 spaces and my cursor ends up exactly where it has to.

However, if I set tab spacing to fontMetrics().width(' ') * 4 then the tab is too short.

So it seems that width is returning a smaller value than what is actually used when the character is part of the text.

For now I'll just work around it by replacing tabs with spaces to get the behavior I want, but I'd still like to get the tab spacing to work right as well. 

Thanks,

Stephan



More information about the Qt-interest-old mailing list