[Qt-interest] QTextEdit: Tab spacing

Malyushytsky, Alex alex at wai.com
Wed Jun 3 03:01:35 CEST 2009


Have you tried to check width of
QRect QFontMetrics::tightBoundingRect ( const QString & text ) const
Of the QString which has 4 spaces?

Alex




-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Stephan Rose
Sent: Tuesday, June 02, 2009 8:42 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] QTextEdit: Tab spacing

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
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list