Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 1311

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/kernel/qfont.cpp:1556 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QFontMetrics Class</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QFontMetrics Class Reference</h1>

<p>The QFontMetrics class provides font metrics information.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qfontmetrics-h.html">qfontmetrics.h</a>&gt;</tt>
<p><a href="qfontmetrics-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn><a href="#QFontMetrics"><b>QFontMetrics</b></a> ( const&nbsp;QFont&nbsp;&amp;&nbsp;font )</div></li>
<li><div class=fn><a href="#QFontMetrics-2"><b>QFontMetrics</b></a> ( const&nbsp;QFontMetrics&nbsp;&amp;&nbsp;fm )</div></li>
<li><div class=fn><a href="#~QFontMetrics"><b>~QFontMetrics</b></a> ()</div></li>
<li><div class=fn>QFontMetrics &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QFontMetrics&nbsp;&amp;&nbsp;fm )</div></li>
<li><div class=fn>int <a href="#ascent"><b>ascent</b></a> () const</div></li>
<li><div class=fn>int <a href="#descent"><b>descent</b></a> () const</div></li>
<li><div class=fn>int <a href="#height"><b>height</b></a> () const</div></li>
<li><div class=fn>int <a href="#leading"><b>leading</b></a> () const</div></li>
<li><div class=fn>int <a href="#lineSpacing"><b>lineSpacing</b></a> () const</div></li>
<li><div class=fn>int <a href="#minLeftBearing"><b>minLeftBearing</b></a> () const</div></li>
<li><div class=fn>int <a href="#minRightBearing"><b>minRightBearing</b></a> () const</div></li>
<li><div class=fn>int <a href="#maxWidth"><b>maxWidth</b></a> () const</div></li>
<li><div class=fn>bool <a href="#inFont"><b>inFont</b></a> ( QChar&nbsp;ch ) const</div></li>
<li><div class=fn>int <a href="#leftBearing"><b>leftBearing</b></a> ( QChar&nbsp;ch ) const</div></li>
<li><div class=fn>int <a href="#rightBearing"><b>rightBearing</b></a> ( QChar&nbsp;ch ) const</div></li>
<li><div class=fn>int <a href="#width"><b>width</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;str, int&nbsp;len = -1 ) const</div></li>
<li><div class=fn>int <a href="#width-2"><b>width</b></a> ( QChar&nbsp;ch ) const</div></li>
<li><div class=fn>int width ( char&nbsp;c ) const &nbsp;<em>(obsolete)</em></div></li>
<li><div class=fn>int <a href="#charWidth"><b>charWidth</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;str, int&nbsp;pos ) const</div></li>
<li><div class=fn>QRect <a href="#boundingRect"><b>boundingRect</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;str, int&nbsp;len = -1 ) const</div></li>
<li><div class=fn>QRect <a href="#boundingRect-2"><b>boundingRect</b></a> ( QChar&nbsp;ch ) const</div></li>
<li><div class=fn>QRect <a href="#boundingRect-3"><b>boundingRect</b></a> ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h, int&nbsp;flgs, const&nbsp;QString&nbsp;&amp;&nbsp;str, int&nbsp;len = -1, int&nbsp;tabstops = 0, int&nbsp;*&nbsp;tabarray = 0, QTextParag&nbsp;**&nbsp;intern = 0 ) const</div></li>
<li><div class=fn>QSize <a href="#size"><b>size</b></a> ( int&nbsp;flgs, const&nbsp;QString&nbsp;&amp;&nbsp;str, int&nbsp;len = -1, int&nbsp;tabstops = 0, int&nbsp;*&nbsp;tabarray = 0, QTextParag&nbsp;**&nbsp;intern = 0 ) const</div></li>
<li><div class=fn>int <a href="#underlinePos"><b>underlinePos</b></a> () const</div></li>
<li><div class=fn>int <a href="#strikeOutPos"><b>strikeOutPos</b></a> () const</div></li>
<li><div class=fn>int <a href="#lineWidth"><b>lineWidth</b></a> () const</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
 
The QFontMetrics class provides font metrics information.
<p> 

<p> QFontMetrics functions calculate size of characters and strings for
a given font. There are three ways you can create a QFontMetrics object:
<p> <ol type=1>
<li> Calling the QFontMetrics constructor with a <a href="qfont.html">QFont</a> creates a font
metrics object for a screen-compatible font, i.e. the font cannot be a
printer font<sup>*</sup>. If the font is changed later, the font
metrics object is <em>not</em> updated.
<p> <li> <a href="qwidget.html#fontMetrics">QWidget::fontMetrics</a>() returns the font metrics for a widget's font.
This is equivalent to QFontMetrics(widget->font()).  If the widget's
font is changed later, the font metrics object is <em>not</em> updated.
<p> <li> <a href="qpainter.html#fontMetrics">QPainter::fontMetrics</a>() returns the font metrics for a painter's
current font. The font metrics object is <em>automatically</em> updated if
you set a new painter font.
</ol>
<p> <sup>*</sup> If you use a printer font the values returned will
almost certainly be inaccurate. Printer fonts are not always
accessible so the nearest screen font is used if a printer font is
supplied.
<p> Once created, the object provides functions to access the individual
metrics of the font, its characters, and for strings rendered in
the font.
<p> There are several functions that operate on the font: <a href="#ascent">ascent</a>(),
<a href="#descent">descent</a>(), <a href="#height">height</a>(), <a href="#leading">leading</a>() and <a href="#lineSpacing">lineSpacing</a>() return the basic
size properties of the font. The <a href="#underlinePos">underlinePos</a>(), <a href="#strikeOutPos">strikeOutPos</a>() and
<a href="#lineWidth">lineWidth</a>() functions, return the properties of the line that
underlines or strikes out the characters.  These functions are all
fast.
<p> There are also some functions that operate on the set of glyphs in
the font: <a href="#minLeftBearing">minLeftBearing</a>(), <a href="#minRightBearing">minRightBearing</a>() and <a href="#maxWidth">maxWidth</a>().  These
are by necessity slow, and we recommend avoiding them if possible.
<p> For each character, you can get its <a href="#width">width</a>(), <a href="#leftBearing">leftBearing</a>() and
<a href="#rightBearing">rightBearing</a>() and find out whether it is in the font using
<a href="#inFont">inFont</a>().  You can also treat the character as a string, and use the
string functions on it.
<p> The string functions include width(), to return the width of a
string in pixels (or points, for a printer), <a href="#boundingRect">boundingRect</a>(), to
return a rectangle large enough to contain the rendered string, and
<a href="#size">size</a>(), to return the size of that rectangle.
<p> Example:
<pre>
    <a href="qfont.html">QFont</a> font( "times", 24 );
    QFontMetrics fm (font );
    int pixelsWide = fm.<a href="#width">width</a>( "What's the width of this text?" );
    int pixelsHigh = fm.<a href="#height">height</a>();
  </pre>
 
<p> <p>See also <a href="qfont.html">QFont</a>, <a href="qfontinfo.html">QFontInfo</a>, <a href="qfontdatabase.html">QFontDatabase</a>, <a href="graphics.html">Graphics Classes</a> and <a href="shared.html">Implicitly and Explicitly Shared Classes</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QFontMetrics"></a>QFontMetrics::QFontMetrics ( const&nbsp;<a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;font )
</h3> Constructs a font metrics object for <em>font</em>.
<p> The font must be screen-compatible, i.e. a font you use when drawing
text in <a href="qwidget.html">QWidget</a> or <a href="qpixmap.html">QPixmap</a> objects, not <a href="qpicture.html">QPicture</a> or <a href="qprinter.html">QPrinter</a>.
<p> The font metrics object holds the information for the font that is
passed in the constructor at the time it is created, and is not
updated if the font's attributes are changed later.
<p> Use <a href="qpainter.html#fontMetrics">QPainter::fontMetrics</a>() to get the font metrics when painting.
This is a little slower than using this constructor, but it always
gives correct results because the font info data is updated.

<h3 class=fn><a name="QFontMetrics-2"></a>QFontMetrics::QFontMetrics ( const&nbsp;<a href="qfontmetrics.html">QFontMetrics</a>&nbsp;&amp;&nbsp;fm )
</h3> Constructs a copy of <em>fm</em>.

<h3 class=fn><a name="~QFontMetrics"></a>QFontMetrics::~QFontMetrics ()
</h3> Destroys the font metrics object and frees all allocated resources.

<h3 class=fn>int <a name="ascent"></a>QFontMetrics::ascent () const
</h3>
Returns the maximum ascent of the font.
<p> The ascent is the distance from the base line to the uppermost line
where pixels may be drawn.
<p> <p>See also <a href="#descent">descent</a>().

<p>Examples: <a href="drawdemo-example.html#x1632">drawdemo/drawdemo.cpp</a> and <a href="scrollview-example.html#x472">scrollview/scrollview.cpp</a>.
<h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect"></a>QFontMetrics::boundingRect ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;str, int&nbsp;len = -1 ) const
</h3>
Returns the bounding rectangle of the first <em>len</em> characters of <em>str</em>, which is the set of pixels the text would cover if drawn at
(0,0).
<p> If <em>len</em> is negative (the default), the entire string is used.
<p> Note that the bounding rectangle may extend to the left of (0,0),
e.g. for italicized fonts, and that the text output may cover <em>all</em>
pixels in the bounding rectangle.
<p> Newline characters are processed as normal characters, <em>not</em> as
linebreaks.
<p> Due to the different actual character heights, the height of the
bounding rectangle of e.g. "Yes" and "yes" may be different.
<p> <p>See also <a href="#width">width</a>() and <a href="qpainter.html#boundingRect">QPainter::boundingRect</a>().

<p>Example: <a href="xform-example.html#x79">xform/xform.cpp</a>.
<h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect-2"></a>QFontMetrics::boundingRect ( <a href="qchar.html">QChar</a>&nbsp;ch ) const
</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns the bounding rectangle of the character <em>ch</em> relative to the
left-most point on the base line.
<p> Note that the bounding rectangle may extend to the left of (0,0),
e.g. for italicized fonts, and that the text output may cover <em>all</em>
pixels in the bounding rectangle.
<p> Note that the rectangle usually extends both above and below the
base line.
<p> <p>See also <a href="#width">width</a>().

<h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect-3"></a>QFontMetrics::boundingRect ( int&nbsp;x, int&nbsp;y, int&nbsp;w, int&nbsp;h, int&nbsp;flgs, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;str, int&nbsp;len = -1, int&nbsp;tabstops = 0, int&nbsp;*&nbsp;tabarray = 0, QTextParag&nbsp;**&nbsp;intern = 0 ) const
</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns the bounding rectangle of the first <em>len</em> characters of <em>str</em>,
which is the set of pixels the text would cover if drawn at (0,0). The
drawing, and hence the bounding rectangle, is constrained to the rectangle
(<em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>).
<p> If <em>len</em> is negative (which is the default), the entire string is used.
<p> The <em>flgs</em> argument is the bitwise OR of the following flags:
<ul>
<li> <tt>AlignAuto</tt> aligns to the left border for all languages except Hebrew and Arabic where it aligns to the right.
<li> <tt>AlignLeft</tt> aligns to the left border.
<li> <tt>AlignRight</tt> aligns to the right border.
<li> <tt>AlignJustify</tt> produces justified text.
<li> <tt>AlignHCenter</tt> aligns horizontally centered.
<li> <tt>AlignTop</tt> aligns to the top border.
<li> <tt>AlignBottom</tt> aligns to the bottom border.
<li> <tt>AlignVCenter</tt> aligns vertically centered
<li> <tt>AlignCenter</tt> (= <tt>AlignHCenter</tt> | AlignVCenter)
<li> <tt>SingleLine</tt> ignores newline characters in the text.
<li> <tt>ExpandTabs</tt> expands tabs (see below)
<li> <tt>ShowPrefix</tt> interprets "&x" as "x" underlined.
<li> <tt>WordBreak</tt> breaks the text to fit the rectangle.
</ul>
<p> Horizontal alignment defaults to AlignAuto and vertical alignment
defaults to AlignTop.
<p> If several of the horizontal or several of the vertical alignment flags
are set, the resulting alignment is undefined.
<p> These flags are defined in qnamespace.h.
<p> If <tt>ExpandTabs</tt> is set in <em>flgs</em>, then:
if <em>tabarray</em> is non-null, it specifies a 0-terminated sequence
of pixel-positions for tabs; otherwise
if <em>tabstops</em> is non-zero, it is used as the tab spacing (in pixels).
<p> Note that the bounding rectangle may extend to the left of (0,0),
e.g. for italicized fonts, and that the text output may cover <em>all</em>
pixels in the bounding rectangle.
<p> Newline characters are processed as linebreaks.
<p> Despite the different actual character heights, the heights of the
bounding rectangles of "Yes" and "yes" are the same.
<p> The bounding rectangle given by this function is somewhat larger
than that calculated by the simpler <a href="#boundingRect">boundingRect</a>() function.  This
function uses the <a href="#minLeftBearing">maximum left</a> and
<a href="#minRightBearing">right</a> font bearings as is necessary
for multi-line text to align correctly.  Also, fontHeight() and
<a href="#lineSpacing">lineSpacing</a>() are used to calculate the height, rather than
individual character heights.
<p> The <em>intern</em> argument should not be used.
<p> <p>See also <a href="#width">width</a>(), <a href="qpainter.html#boundingRect">QPainter::boundingRect</a>() and <a href="qt.html#AlignmentFlags-enum">Qt::AlignmentFlags</a>.

<h3 class=fn>int <a name="charWidth"></a>QFontMetrics::charWidth ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;str, int&nbsp;pos ) const
</h3>
Returns the width of the character at position <em>pos</em> in the string
<em>str</em>.
<p> The whole string is needed, as the glyph drawn may change depending on the
context (the letter before and after the current one) for some languages
(e.g. Arabic).
<p> This function also takes non spacing marks and ligatures into account.

<h3 class=fn>int <a name="descent"></a>QFontMetrics::descent () const
</h3>
Returns the maximum descent of the font.
<p> 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.)
<p> <p>See also <a href="#ascent">ascent</a>().

<p>Examples: <a href="drawdemo-example.html#x1633">drawdemo/drawdemo.cpp</a> and <a href="hello-example.html#x1456">hello/hello.cpp</a>.
<h3 class=fn>int <a name="height"></a>QFontMetrics::height () const
</h3>
Returns the height of the font.
<p> This is always equal to <a href="#ascent">ascent</a>()+descent()+1 (the 1 is for the base line).
<p> <p>See also <a href="#leading">leading</a>() and <a href="#lineSpacing">lineSpacing</a>().

<p>Examples: <a href="grapher-nsplugin-example.html#x2593">grapher/grapher.cpp</a>, <a href="hello-example.html#x1457">hello/hello.cpp</a> and <a href="qfd-example.html#x732">qfd/fontdisplayer.cpp</a>.
<h3 class=fn>bool <a name="inFont"></a>QFontMetrics::inFont ( <a href="qchar.html">QChar</a>&nbsp;ch ) const
</h3>
Returns TRUE if character <em>ch</em> is a valid character in the font;
otherwise returns FALSE.

<p>Example: <a href="qfd-example.html#x733">qfd/fontdisplayer.cpp</a>.
<h3 class=fn>int <a name="leading"></a>QFontMetrics::leading () const
</h3>
Returns the leading of the font.
<p> This is the natural inter-line spacing.
<p> <p>See also <a href="#height">height</a>() and <a href="#lineSpacing">lineSpacing</a>().

<h3 class=fn>int <a name="leftBearing"></a>QFontMetrics::leftBearing ( <a href="qchar.html">QChar</a>&nbsp;ch ) const
</h3>
Returns the left bearing of character <em>ch</em> in the font.
<p> The left bearing is the right-ward distance of the left-most pixel
of the character from the logical origin of the character.
This value is negative if the pixels of the character extend
to the left of the logical origin.
<p> See <a href="#width">width</a>(<a href="qchar.html">QChar</a>) for a graphical description of this metric.
<p> <p>See also <a href="#rightBearing">rightBearing</a>(), <a href="#minLeftBearing">minLeftBearing</a>() and <a href="#width">width</a>().

<p>Example: <a href="qfd-example.html#x734">qfd/fontdisplayer.cpp</a>.
<h3 class=fn>int <a name="lineSpacing"></a>QFontMetrics::lineSpacing () const
</h3> Returns the distance from one base line to the next.
<p> This value is always equal to <a href="#leading">leading</a>()+height().
<p> <p>See also <a href="#height">height</a>() and <a href="#leading">leading</a>().

<p>Examples: <a href="qaction-application-example.html#x2022">action/application.cpp</a>, <a href="simple-application-example.html#x1919">application/application.cpp</a>, <a href="mdi-example.html#x1145">mdi/application.cpp</a>, <a href="qfd-example.html#x735">qfd/fontdisplayer.cpp</a>, <a href="qwerty-example.html#x631">qwerty/qwerty.cpp</a> and <a href="scrollview-example.html#x473">scrollview/scrollview.cpp</a>.
<h3 class=fn>int <a name="lineWidth"></a>QFontMetrics::lineWidth () const
</h3>
Returns the width of the underline and strikeout lines, adjusted for
the point size of the font.
<p>See also <a href="#underlinePos">underlinePos</a>() and <a href="#strikeOutPos">strikeOutPos</a>().

<h3 class=fn>int <a name="maxWidth"></a>QFontMetrics::maxWidth () const
</h3>
Returns the width of the widest character in the font.

<p>Example: <a href="qfd-example.html#x736">qfd/fontdisplayer.cpp</a>.
<h3 class=fn>int <a name="minLeftBearing"></a>QFontMetrics::minLeftBearing () const
</h3>
Returns the minimum left bearing of the font.
<p> This is the smallest <a href="#leftBearing">leftBearing</a>(char) of all characters in the font.
<p> Note that this function can be very slow if the font is large.
<p> <p>See also <a href="#minRightBearing">minRightBearing</a>() and <a href="#leftBearing">leftBearing</a>().

<p>Example: <a href="qfd-example.html#x737">qfd/fontdisplayer.cpp</a>.
<h3 class=fn>int <a name="minRightBearing"></a>QFontMetrics::minRightBearing () const
</h3>
Returns the minimum right bearing of the font.
<p> This is the smallest <a href="#rightBearing">rightBearing</a>(char) of all characters in the
font.
<p> Note that this function can be very slow if the font is large.
<p> <p>See also <a href="#minLeftBearing">minLeftBearing</a>() and <a href="#rightBearing">rightBearing</a>().

<p>Example: <a href="qfd-example.html#x738">qfd/fontdisplayer.cpp</a>.
<h3 class=fn><a href="qfontmetrics.html">QFontMetrics</a>&nbsp;&amp; <a name="operator-eq"></a>QFontMetrics::operator= ( const&nbsp;<a href="qfontmetrics.html">QFontMetrics</a>&nbsp;&amp;&nbsp;fm )
</h3> Assigns the font metrics <em>fm</em>.

<h3 class=fn>int <a name="rightBearing"></a>QFontMetrics::rightBearing ( <a href="qchar.html">QChar</a>&nbsp;ch ) const
</h3>
Returns the right bearing of character <em>ch</em> in the font.
<p> The right bearing is the left-ward distance of the right-most pixel
of the character from the logical origin of a subsequent character.
This value is negative if the pixels of the character extend
to the right of the <a href="#width">width</a>() of the character.
<p> See width() for a graphical description of this metric.
<p> <p>See also <a href="#leftBearing">leftBearing</a>(), <a href="#minRightBearing">minRightBearing</a>() and <a href="#width">width</a>().

<p>Example: <a href="qfd-example.html#x739">qfd/fontdisplayer.cpp</a>.
<h3 class=fn><a href="qsize.html">QSize</a> <a name="size"></a>QFontMetrics::size ( int&nbsp;flgs, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;str, int&nbsp;len = -1, int&nbsp;tabstops = 0, int&nbsp;*&nbsp;tabarray = 0, QTextParag&nbsp;**&nbsp;intern = 0 ) const
</h3> Returns the size in pixels of the first <em>len</em> characters of <em>str</em>.
<p> If <em>len</em> is negative (the default), the entire string is used.
<p> The <em>flgs</em> argument is the bitwise OR of the following flags:
<ul>
<li> <tt>SingleLine</tt> ignores newline characters.
<li> <tt>ExpandTabs</tt> expands tabs (see below)
<li> <tt>ShowPrefix</tt> interprets "&x" as "x" underlined.
<li> <tt>WordBreak</tt> breaks the text to fit the rectangle.
</ul>
<p> These flags are defined in qnamespace.h.
<p> If <tt>ExpandTabs</tt> is set in <em>flgs</em>, then:
if <em>tabarray</em> is non-null, it specifies a 0-terminated sequence
of pixel-positions for tabs; otherwise
if <em>tabstops</em> is non-zero, it is used as the tab spacing (in pixels).
<p> Newline characters are processed as linebreaks.
<p> Despite the different actual character heights, the heights of the
bounding rectangles of "Yes" and "yes" are the same.
<p> The <em>intern</em> argument should not be used.
<p> <p>See also <a href="#boundingRect">boundingRect</a>().

<h3 class=fn>int <a name="strikeOutPos"></a>QFontMetrics::strikeOutPos () const
</h3>
Returns the distance from the base line to where the strikeout line
should be drawn.
<p>See also <a href="#underlinePos">underlinePos</a>() and <a href="#lineWidth">lineWidth</a>().

<h3 class=fn>int <a name="underlinePos"></a>QFontMetrics::underlinePos () const
</h3>
Returns the distance from the base line to where an underscore should be
drawn.
<p>See also <a href="#strikeOutPos">strikeOutPos</a>() and <a href="#lineWidth">lineWidth</a>().

<h3 class=fn>int <a name="width"></a>QFontMetrics::width ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;str, int&nbsp;len = -1 ) const
</h3>
Returns the width in pixels of the first <em>len</em> characters of <em>str</em>. If <em>len</em> is negative (the default), the entire string is used.
<p> Note that this value is <em>not</em> equal to <a href="#boundingRect">boundingRect</a>().<a href="#width">width</a>();
boundingRect() returns a rectangle describing the pixels this string
will cover whereas width() returns the distance to where the next string
should be drawn.
<p> <p>See also <a href="#boundingRect">boundingRect</a>().

<p>Examples: <a href="drawdemo-example.html#x1634">drawdemo/drawdemo.cpp</a>, <a href="hello-example.html#x1458">hello/hello.cpp</a>, <a href="movies-example.html#x1083">movies/main.cpp</a>, <a href="qfd-example.html#x740">qfd/fontdisplayer.cpp</a> and <a href="scrollview-example.html#x474">scrollview/scrollview.cpp</a>.
<h3 class=fn>int <a name="width-2"></a>QFontMetrics::width ( <a href="qchar.html">QChar</a>&nbsp;ch ) const
</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <img src="bearings.png" align=right>
<p> Returns the logical width of character <em>ch</em> in pixels.  This is a
distance appropriate for drawing a subsequent character after <em>ch</em>.
<p> Some of the metrics are described in the image to the right.  The
tall dark rectangle covers the logical <a href="#width">width</a>() of a character.  The
shorter pale rectangles cover <a href="#leftBearing">leftBearing</a>() and <a href="#rightBearing">rightBearing</a>() of
the characters.  Notice that the bearings of "f" in this particular
font are both negative, while the bearings of "o" are both positive.
<p> <b>Warning:</b> This function will produce incorrect results for Arabic
characters or non spacing marks in the middle of a string, as the
glyph shaping  and positioning of marks  that happens when processing
strings cannot be taken into account. Use <a href="#charWidth">charWidth</a>() instead if you
aren't looking for the width of isolated characters.
<p> <p>See also <a href="#boundingRect">boundingRect</a>() and <a href="#charWidth">charWidth</a>().

<h3 class=fn>int <a name="width-3"></a>QFontMetrics::width ( char&nbsp;c ) const
</h3> 
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.
<p> Provided to aid porting from Qt 1.x.

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2001
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>