QFontMetrics Class Reference


QFontMetrics gives size information for a font. (details) (complete member list)

#include <qfontmet.h>

Public Members


Detailed Description

QFontMetrics gives size information for a font.


Member Function Documentation

QFontMetrics::QFontMetrics (const QFont &font)

Constructs a new object that operates on font.

See also: setFont().

int QFontMetrics::ascent () const

Returns the maximum ascent of the font. The ascent is the distance from the base line to the uppermost line where pixels may be drawn.

QRect QFontMetrics::boundingRect (const char *str, int len = -1) const

Returns the bounding rectangle of the first len characters of str.

if len is negative or larger than the length of str, the whole string is used.

Note that the bounding rectangle may extend to the left of (0,0) and that the text output may cover all pixels in the bounding rectangle.

QRect QFontMetrics::boundingRect (char ch) const

Returns the bounding rectangle of ch. Note that the bounding rectangle may extend to the left of (0,0) and that the text output may cover all pixels in the bounding rectangle.

int QFontMetrics::descent () const

Returns the maximum descent of the font. The descent is the distance from the base line to the lowermost line where pixels may be drawn. (Note that this is different from X, which adds 1 pixel.).

const QFont & QFontMetrics::font () const

Returns the font this object operates on.

int QFontMetrics::height () const

Returns the height of the font. This is always equal to ascent()+descent()+1 (the 1 is for the base line).

See also: leading().

int QFontMetrics::leading () const

Returns the leading of the font in pixels. This is the natural inter-line spacing.

See also: height().

int QFontMetrics::lineSpacing () const

Returns the distance from one base line to the next. This value is always equal to leading()+height().

See also: height(), leading().

int QFontMetrics::lineWidth () const

Returns the width of the underline and strike-out lines, adjusted for the point size of the font.

See also: underlinePos(), strikeOutPos().

int QFontMetrics::maxWidth () const

Returns the width of the widest character in the font.

void QFontMetrics::setFont (const QFont &font)

Sets the font this object operates on.

int QFontMetrics::strikeOutPos () const

Returns the distance from the base line to where the strike-out line should be drawn.

See also: underlinePos(), lineWidth().

int QFontMetrics::underlinePos () const

Returns the distance from the base line to where an underscore should be drawn.

See also: strikeOutPos(), lineWidth().

int QFontMetrics::width (const char *str, int len = -1) const

Returns the width in pixels of the first len characters of str.

if len is negative or larger than the length of str, the whole string is used.

Note that this value is not equal to boundingRect().width(); boundingRect() returns a rectangle desribing the pixels this string will cover whereas width() returns the distance to where the next string should be drawn. Thus, width(stra)+width(strb) is always equal to width(strcat(stra, strb)). This is almost never the case with boundingRect().

int QFontMetrics::width (char ch) const

Returns the pixel width of a ch.


This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 16:17, 1995/06/30 by the webmaster at Troll Tech