Sophie

Sophie

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

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/qstylesheet.cpp:765 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QStyleSheet 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>QStyleSheet Class Reference</h1>

<p>The QStyleSheet class is a collection of styles for rich text
rendering and a generator of tags.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qstylesheet-h.html">qstylesheet.h</a>&gt;</tt>
<p>Inherits <a href="qobject.html">QObject</a>.
<p><a href="qstylesheet-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn><a href="#QStyleSheet"><b>QStyleSheet</b></a> ( QObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</div></li>
<li><div class=fn>virtual <a href="#~QStyleSheet"><b>~QStyleSheet</b></a> ()</div></li>
<li><div class=fn>QStyleSheetItem * <a href="#item"><b>item</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name )</div></li>
<li><div class=fn>const QStyleSheetItem * <a href="#item-2"><b>item</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name ) const</div></li>
<li><div class=fn>virtual QTextCustomItem * <a href="#tag"><b>tag</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name, const&nbsp;QMap&lt;QString,&nbsp;QString&gt;&nbsp;&amp;&nbsp;attr, const&nbsp;QString&nbsp;&amp;&nbsp;context, const&nbsp;QMimeSourceFactory&nbsp;&amp;&nbsp;factory, bool&nbsp;emptyTag, QTextDocument&nbsp;*&nbsp;doc ) const</div></li>
<li><div class=fn>virtual void <a href="#scaleFont"><b>scaleFont</b></a> ( QFont&nbsp;&amp;&nbsp;font, int&nbsp;logicalSize ) const</div></li>
<li><div class=fn>virtual void <a href="#error"><b>error</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;msg ) const</div></li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class=fn>QStyleSheet * <a href="#defaultSheet"><b>defaultSheet</b></a> ()</div></li>
<li><div class=fn>void <a href="#setDefaultSheet"><b>setDefaultSheet</b></a> ( QStyleSheet&nbsp;*&nbsp;sheet )</div></li>
<li><div class=fn>QString <a href="#escape"><b>escape</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;plain )</div></li>
<li><div class=fn>QString <a href="#convertFromPlainText"><b>convertFromPlainText</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;plain, QStyleSheetItem::WhiteSpaceMode&nbsp;mode = QStyleSheetItem::WhiteSpacePre )</div></li>
<li><div class=fn>bool <a href="#mightBeRichText"><b>mightBeRichText</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;text )</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>



The QStyleSheet class is a collection of styles for rich text
rendering and a generator of tags.
<p> 

<p> By creating <a href="qstylesheetitem.html">QStyleSheetItem</a> objects for a style sheet you build a
definition of a set of tags.  This definition will be used by the
internal rich text rendering system to parse and display text
documents to which the style sheet applies. Rich text is normally
visualized in a QTextView or a <a href="qtextbrowser.html">QTextBrowser</a>. However, <a href="qlabel.html">QLabel</a>,
<a href="qwhatsthis.html">QWhatsThis</a> and <a href="qmessagebox.html">QMessageBox</a> also support it, and other classes are
likely to follow. With <a href="qsimplerichtext.html">QSimpleRichText</a> it is possible to use the
rich text renderer for custom widgets as well.
<p> The default QStyleSheet object has the following style bindings,
sorted by structuring bindings, anchors, character style bindings
(i.e. inline styles), special elements such as horizontal lines or
images, and other tags. In addition, rich text supports simple HTML
tables.
<p> The structuring tags are
<ul>
<li> <tt>&lt;qt&gt;</tt>...<tt>&lt;/qt&gt;</tt>
- A Qt rich text document. It understands the following attributes:
<ul>
<li> title
- The caption of the document. This attribute is easily accessible with
<a href="qtextedit.html#documentTitle">QTextView::documentTitle</a>().
<li> type
- The type of the document. The default type is <tt>page</tt> . It
indicates that the document is displayed in a page of its
own. Another style is <tt>detail</tt>, which can be used to
explain certain expressions in more detail in a few
sentences. The <a href="qtextbrowser.html">QTextBrowser</a> will then keep the current page
and display the new document in a small popup similar to
<a href="qwhatsthis.html">QWhatsThis</a>. Note that links will not work in documents with
<tt>&lt;qt type="detail"&gt;...&lt;/qt&gt;</tt>.
<li> bgcolor
- The background color, for example <tt>bgcolor="yellow"</tt> or <tt>bgcolor="#0000FF"</tt>.
<li> background
- The background pixmap, for example <tt>background="granit.xpm"</tt>. The pixmap name will be resolved by
a <a href="qmimesourcefactory.html">QMimeSourceFactory</a>().
<li> text
- The default text color, for example <tt>text="red"</tt>.
<li> link
- The link color, for example <tt>link="green"</tt>.
</ul>
<li> <tt>&lt;h1&gt;...&lt;/h1&gt;</tt>
- A top-level heading.
<li> <tt>&lt;h2&gt;...&lt;/h2&gt;</tt>
- A sublevel heading.
<li> <tt>&lt;h3&gt;...&lt;/h3&gt;</tt>
- A sub-sublevel heading.
<li> <tt>&lt;p&gt;...&lt;/p&gt;</tt>
- A left-aligned paragraph. Adjust the alignment with
the  <tt>align</tt> attribute. Possible values are
<tt>left</tt>, <tt>right</tt> and <tt>center</tt>.
<li> <tt>&lt;center&gt;...&lt;/center&gt;</tt>
- A centered paragraph.
<li> <tt>&lt;blockquote&gt;...&lt;/blockquote&gt;</tt>
- An indented paragraph that is useful for quotes.
<li> <tt>&lt;ul&gt;...&lt;/ul&gt;</tt>
- An unordered list. You can also pass a type argument to
define the bullet style. The default is <tt>type=disc</tt>; other
types are <tt>circle</tt> and <tt>square</tt>.
<li> <tt>&lt;ol&gt;...&lt;/ol&gt;</tt>
- An ordered list. You can also pass a type argument to define
the enumeration label style. The default is <tt>type="1"</tt>; other
types are <tt>"a"</tt> and <tt>"A"</tt>.
<li> <tt>&lt;li&gt;</tt>...<tt>&lt;/li&gt;</tt>
- A list item. This tag can be used only within the context of
<tt>ol</tt> or <tt>ul</tt>.
<li> <tt>&lt;pre&gt;...&lt;/pre&gt;</tt>
- For larger chunks of code. Whitespaces in the contents are preserved.
For small bits of code use the inline-style <tt>code</tt>.
</ul>
<p> Anchors and links are done with a single tag:
<ul>
<li> <tt>&lt;a&gt;...&lt;/a&gt;</tt>
- An anchor or link. The reference target is defined in the <tt>href</tt> attribute of the tag as in <tt>&lt;a href="target.qml"&gt;...&lt;/a&gt;</tt>. You can also specify an
additional anchor within the specified target document, for
example <tt>&lt;a href="target.qml#123"&gt;...&lt;/a&gt;</tt>. If <tt>a</tt> is
meant to be an anchor, the reference source is given in the
<a href="qobject.html#name-prop">name</a> attribute.
</ul>
<p> The default character style bindings are
<ul>
<li> <tt>&lt;em&gt;...&lt;/em&gt;</tt>
- Emphasized. By default this is the same as
<tt>&lt;i&gt;...&lt;/i&gt;</tt> (italic).
<li> <tt>&lt;strong&gt;...&lt;/strong&gt;</tt>
- Strong. By default this is the same as
<tt>&lt;b&gt;...&lt;/b&gt;</tt> (bold).
<li> <tt>&lt;i&gt;...&lt;/i&gt;</tt>
- Italic font style.
<li>  <tt>&lt;b&gt;...&lt;/b&gt;</tt>
- Bold font style.
<li>  <tt>&lt;u&gt;...&lt;/u&gt;</tt>
- Underlined font style.
<li>  <tt>&lt;big&gt;...&lt;/big&gt;</tt>
- A larger font size.
<li>  <tt>&lt;small&gt;...&lt;/small&gt;</tt>
- A smaller font size.
<li>  <tt>&lt;code&gt;...&lt;/code&gt;</tt>
- Indicates code. By default this is the same as
<tt>&lt;tt&gt;...&lt;/tt&gt;</tt> (typewriter). For
larger junks of code use the block-tag <tt>pre</tt>.
<li>  <tt>&lt;tt&gt;...&lt;/tt&gt;</tt>
- Typewriter font style.
<li>  <tt>&lt;font&gt;...&lt;/font&gt;</tt>
- Customizes the font size, family  and text color. The tag understands
the following  attributes:
<ul>
<li> color
- The text color, for example <tt>color="red"</tt> or <tt>color="#FF0000"</tt>.
<li> size
- The logical size of the font. Logical sizes 1 to 7 are supported.
The value may either be absolute (for example,
<tt>size=3</tt>) or relative (<tt>size=-2</tt>). In the latter case the sizes
are simply added.
<li> face
- The family of the font, for example <tt>face=times</tt>.
</ul>
</ul>
<p> Special elements are:
<ul>
<li> <tt>&lt;img&gt;</tt>
- An image. The image name for the mime source
factory is given in the source attribute, for example
<tt>&lt;img src="qt.xpm"&gt;</tt>
The image tag also understands the attributes <tt>width</tt> and <tt>height</tt> that determine the size of the image. If the pixmap
does not fit the specified size it will be scaled
automatically (by using <a href="qimage.html#smoothScale">QImage::smoothScale</a>()).
<p> The <tt>align</tt> attribute determines where the image is
placed. By default, an image is placed inline just like a
normal character. Specify <tt>left</tt> or <tt>right</tt> to place the
image at the respective side.
<li> <tt>&lt;hr&gt;</tt>
- A horizonal line.
<li> <tt>&lt;br&gt;</tt>
- A line break.
</ul>
<p> Another tag not in any of the above cathegories is
<ul>
<li> <tt>&lt;nobr&gt;...&lt;/nobr&gt;</tt>
- No break. Prevents word wrap.
</ul>
<p> In addition, rich text supports simple HTML tables. A table consists
of one or more rows each of which contains one or more cells. Cells
are either data cells or header cells, depending on their
content. Cells which span rows and columns are supported.
<p> <ul>
<li> <tt>&lt;table&gt;...&lt;/table&gt;</tt>
- A table. Tables support the following attributes:
<ul>
<li> bgcolor
- The background color.
<li> width
- The table width. This is either an absolute pixel width or a relative
percentage of the table's width, for example <tt>width=80%</tt>.
<li> border
- The width of the table border. The default is 0 (= no border).
<li> cellspacing
- Additional space around the table cells. The default is 2.
<li> cellpadding
- Additional space around the contents of table cells. The default is 1.
</ul>
<li> <tt>&lt;tr&gt;...&lt;/tr&gt;</tt>
- A table row. This is only valid within a <tt>table</tt>. Rows support
the following attribute:
<ul>
<li> bgcolor
- The background color.
</ul>
<li> <tt>&lt;th&gt;...&lt;/th&gt;</tt>
- A table header cell. Similar to <tt>td</tt>, but defaults to center alignment
and a bold font.
<li> <tt>&lt;td&gt;...&lt;/td&gt;</tt>
- A table data cell. This is only valid within a <tt>tr</tt>. Cells
support the following attributes:
<ul>
<li> bgcolor
- The background color.
<li> width
- The cell width. This is either an absolute pixel width or a relative
percentage of table's width, for example <tt>width=50%</tt>.
<li> colspan
- Specifies how many columns this cell spans. The default is 1.
<li> rowspan
- Specifies how many rows this cell spans. The default is 1.
<li> align
- Alignment; possible values are <tt>left</tt>, <tt>right</tt>, and <tt>center</tt>. The
default is left.
</ul>
</ul>
<p>See also <a href="graphics.html">Graphics Classes</a>, <a href="helpsystem.html">Help System</a> and <a href="text.html">Text Related Classes</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QStyleSheet"></a>QStyleSheet::QStyleSheet ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Creates a style sheet with parent <em>parent</em> and name <em>name</em>.  Like
any <a href="qobject.html">QObject</a> it will be deleted when its parent is
destroyed (if the child still exists).
<p> By default the style sheet has the tag definitions defined above.

<h3 class=fn><a name="~QStyleSheet"></a>QStyleSheet::~QStyleSheet ()<tt> [virtual]</tt>
</h3>
Destroys the style sheet.  All styles inserted into the style sheet
will be deleted.

<h3 class=fn><a href="qstring.html">QString</a> <a name="convertFromPlainText"></a>QStyleSheet::convertFromPlainText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;plain, <a href="qstylesheetitem.html#WhiteSpaceMode-enum">QStyleSheetItem::WhiteSpaceMode</a>&nbsp;mode = QStyleSheetItem::WhiteSpacePre )<tt> [static]</tt>
</h3>
Auxiliary function. Converts the plain text string <em>plain</em> to a
rich text formatted paragraph while preserving its look.
<p> <em>mode</em> defines the whitespace mode. Possible values are <a href="qstylesheetitem.html#WhiteSpaceMode-enum">QStyleSheetItem::WhiteSpacePre</a> (no wrapping, all whitespaces
preserved) and <a href="qstylesheetitem.html#WhiteSpaceMode-enum">QStyleSheetItem::WhiteSpaceNormal</a> (wrapping,
simplified whitespaces).
<p> <p>See also <a href="#escape">escape</a>().

<h3 class=fn><a href="qstylesheet.html">QStyleSheet</a>&nbsp;* <a name="defaultSheet"></a>QStyleSheet::defaultSheet ()<tt> [static]</tt>
</h3>
Returns the application-wide default style sheet. This style sheet is
used by rich text rendering classes such as <a href="qsimplerichtext.html">QSimpleRichText</a>,
<a href="qwhatsthis.html">QWhatsThis</a> and <a href="qmessagebox.html">QMessageBox</a> to define the rendering style and
available tags within rich text documents. It serves also as initial
style sheet for the more complex render widgets <a href="qtextedit.html">QTextEdit</a> and
<a href="qtextbrowser.html">QTextBrowser</a>.
<p> <p>See also <a href="#setDefaultSheet">setDefaultSheet</a>().

<h3 class=fn>void <a name="error"></a>QStyleSheet::error ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;msg ) const<tt> [virtual]</tt>
</h3> 
<p> This virtual function is called when an error occurs when
processing rich text. Reimplement it if you need to catch
error messages.
<p> Errors might occur if some rich text strings contain tags that are
not understood by the stylesheet, if some tags are nested incorrectly, or
if tags are not closed properly.
<p> <em>msg</em> is the error message.

<h3 class=fn><a href="qstring.html">QString</a> <a name="escape"></a>QStyleSheet::escape ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;plain )<tt> [static]</tt>
</h3>
Auxiliary function. Converts the plain text string <em>plain</em> to a
rich text formatted string with any HTML meta-characters escaped.
<p> <p>See also <a href="#convertFromPlainText">convertFromPlainText</a>().

<h3 class=fn><a href="qstylesheetitem.html">QStyleSheetItem</a>&nbsp;* <a name="item"></a>QStyleSheet::item ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name )
</h3>
Returns the style with name <em>name</em> or 0 if there is no such style.

<h3 class=fn>const&nbsp;<a href="qstylesheetitem.html">QStyleSheetItem</a>&nbsp;* <a name="item-2"></a>QStyleSheet::item ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns the style with name <em>name</em> or 0 if there is no such style (const version)

<h3 class=fn>bool <a name="mightBeRichText"></a>QStyleSheet::mightBeRichText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text )<tt> [static]</tt>
</h3>
Returns TRUE if the string <em>text</em> is likely to be rich text;
otherwise returns FALSE.
<p> Note: The function uses a fast and therefore simple heuristic. It
mainly checks whether there is something that looks like a tag
before the first line break. Although the result may be correct for
most common cases, there is no guarantee.

<h3 class=fn>void <a name="scaleFont"></a>QStyleSheet::scaleFont ( <a href="qfont.html">QFont</a>&nbsp;&amp;&nbsp;font, int&nbsp;logicalSize ) const<tt> [virtual]</tt>
</h3>
Scales the font <em>font</em> to the appropriate physical point size
corresponding to the logical font size <em>logicalSize</em>.
<p> When calling this function, <em>font</em> has a point size corresponding to
the logical font size 3.
<p> Logical font sizes range from 1 to 7, with 1 being the smallest.
<p> <p>See also <a href="qstylesheetitem.html#logicalFontSize">QStyleSheetItem::logicalFontSize</a>(), <a href="qstylesheetitem.html#logicalFontSizeStep">QStyleSheetItem::logicalFontSizeStep</a>() and <a href="qfont.html#setPointSize">QFont::setPointSize</a>().

<h3 class=fn>void <a name="setDefaultSheet"></a>QStyleSheet::setDefaultSheet ( <a href="qstylesheet.html">QStyleSheet</a>&nbsp;*&nbsp;sheet )<tt> [static]</tt>
</h3>
Sets the application-wide default style sheet to <em>sheet</em>, deleting
any style sheet previously set. The ownership is transferred to
QStyleSheet.
<p> <p>See also <a href="#defaultSheet">defaultSheet</a>().

<h3 class=fn>QTextCustomItem * <a name="tag"></a>QStyleSheet::tag ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name, const&nbsp;<a href="qmap.html">QMap</a>&lt;QString,&nbsp;QString&gt;&nbsp;&amp;&nbsp;attr, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;context, const&nbsp;<a href="qmimesourcefactory.html">QMimeSourceFactory</a>&nbsp;&amp;&nbsp;factory, bool&nbsp;emptyTag, QTextDocument&nbsp;*&nbsp;doc ) const<tt> [virtual]</tt>
</h3>
<p><b>This function is under development and is subject to change.</b>
<p> Generates an internal object for the tag called <em>name</em>, given the
attributes <em>attr</em>, and using additional information provided
by the mime source factory <em>factory</em>.
<p> <em>context</em> is the optional context of the document, i.e. the path to
look for relative links. This becomes important if the text contains
relative references, for example within image tags. <a href="qsimplerichtext.html">QSimpleRichText</a>
always uses the default mime source factory (see
<a href="qmimesourcefactory.html#defaultFactory">QMimeSourceFactory::defaultFactory</a>()) to resolve these references.
The context will then be used to calculate the absolute path. See
<a href="qmimesourcefactory.html#makeAbsolute">QMimeSourceFactory::makeAbsolute</a>() for details.
<p> <em>emptyTag</em> and <em>doc</em> are for internal use only.
<p> This function should not (yet) be used in application code.

<!-- 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>