File: qstylesheet.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (309 lines) | stat: -rw-r--r-- 17,290 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - 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: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QStyleSheet Class Reference</h1><br clear="all">
<p>
A collection of styles for rich text rendering and a generator of tags.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qstylesheet-h.html">qstylesheet.h</a>&gt;</code>
<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="#0664aa"><b>QStyleSheet</b></a>(QObject*parent=0, constchar*name=0)</div>
<li><div class="fn">virtual<a href="#d4c965"><b>~QStyleSheet</b></a>()</div>
<li><div class="fn">QStyleSheetItem*<a href="#a6efac"><b>item</b></a>(constQString&amp;name)</div>
<li><div class="fn">constQStyleSheetItem*<a href="#2749ea"><b>item</b></a>(constQString&amp;name)const</div>
<li><div class="fn">void<b>insert</b>(QStyleSheetItem*item)(internal)</div>
<li><div class="fn">virtualQTextCustomItem*<a href="#12755e"><b>tag</b></a>(constQString&amp;name, constQMap&lt;QString, QString&gt;&amp;attr, constQString&amp;context, constQMimeSourceFactory&amp;factory, boolemptyTag=FALSE)const</div>
<li><div class="fn">virtualvoid<a href="#9a27e3"><b>scaleFont</b></a>(QFont&amp;font, intlogicalSize)const</div>
<li><div class="fn">virtualvoid<a href="#fcd933"><b>error</b></a>(constQString&amp;)const</div>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class="fn">QStyleSheet*<a href="#50ded7"><b>defaultSheet</b></a>()</div>
<li><div class="fn">void<a href="#0aa4a1"><b>setDefaultSheet</b></a>(QStyleSheet*)</div>
<li><div class="fn">QString<a href="#e1e9e8"><b>convertFromPlainText</b></a>(constQString&amp;)</div>
<li><div class="fn">bool<a href="#58b86f"><b>mightBeRichText</b></a>(constQString&amp;)</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
A collection of styles for rich text rendering and a generator of tags.
<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 <a href="qtextview.html">QTextView</a> or a <a href="qtextbrowser.html">QTextBrowser</a>. But also <a href="qlabel.html">QLabel</a>,
<a href="qwhatsthis.html">QWhatsThis</a> and <a href="qmessagebox.html">QMessageBox</a> support it for now, with others 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 like horizontal lines or
images and other tags. In addition, rich text supports simple HTML
tables.
<p>The structuring tags are:
<ul>
<li><code>&lt;qt&gt;...&lt;/qt&gt;</code>
- A Qt rich text document. It understands the following attributes
<ul>
<li> <code>title</code>
- the caption of the document. This attribute is easily accessible with
<a href="qtextview.html#ac4c3f">QTextView::documentTitle</a>()
<li> <code>type</code>
- The type of the document. The default type is <code>page</code> . It indicates that
the document is displayed in a page of its own. Another style is <code>detail.</code>
It can be used to explain certain expressions more detailed in a few
sentences. The QTextBrowser will then keep the current page and display the
new document in a small popup similar to QWhatsThis. Note that links
will not work in documents with <code>&lt;qt type="detail" &gt;...&lt;/qt&gt;</code>
<li> <code>bgcolor</code>
- The background color, for example <code>bgcolor="yellow"</code> or <code>bgcolor="#0000FF"</code>
<li> <code>background</code>
- The background pixmap, for example <code>background="granit.xpm".</code> The pixmap name
will be resolved by a <a href="qmimesourcefactory.html">QMimeSourceFactory</a>().
<li> <code>text</code>
- The default text color, for example <code>text="red"</code>
<li> <code>link</code>
- The link color, for example <code>link="green"</code>
</ul>
<li><code>&lt;h1&gt;...&lt;/h1&gt;</code>
- A top-level heading.
<li><code>&lt;h2&gt;...&lt;/h2&gt;</code>
- A sub-level heading.
<li><code>&lt;h3&gt;...&lt;/h3&gt;</code>
- A sub-sub-level heading.
<li><code>&lt;p&gt;...&lt;/p&gt;</code>
- A left-aligned paragraph. Adjust the alignment with
the  <code>align</code> attribute. Possible values are
<code>left, right</code> and <code>center.</code>
<li><code>&lt;center&gt;...&lt;/center&gt;</code>
- A centered paragraph.
<li><code>&lt;blockquote&gt;...&lt;/blockquote&gt;</code>
- An indented paragraph, useful for quotes.
<li><code>&lt;ul&gt;...&lt;/ul&gt;</code>
- An un-ordered list. You can also pass a type argument to
define the bullet style. The default is <code>type=disc,</code>  other
types are <code>circle</code> and <code>square.</code>
<li><code>&lt;ol&gt;...&lt;/ol&gt;</code>
- An ordered list. You can also pass a type argument to define
the enumeration label style. The default is <code>type="1",</code> other
types are <code>"a"</code> and <code>"A".</code>
<li><code>&lt;li&gt;...&lt;/li&gt;</code>
- A list item. This tag can only be used within the context of
<code>ol</code> or <code>ul.</code>
<li><code>&lt;pre&gt;...&lt;/pre&gt;</code>
- For larger junks of code. Whitespaces in the contents are preserved.
For small bits of code, use the inline-style <code>code.</code>
</ul>
<p>Anchors and links are done with a single tag:
<ul>
<li><code>&lt;a&gt;...&lt;/a&gt;</code>
- An anchor or link. The reference target is defined in the
<code>href</code> attribute of the tag as in <code>&lt;a href="target.qml"&gt;...&lt;/a&gt;.</code>
You can also specify an additional anchor within the specified target document, for
example <code>&lt;a href="target.qml#123"&gt;...&lt;/a&gt;.</code>  If
<code>a</code> is meant to be an anchor, the reference source is given in
the <code>name</code> attribute.
</ul>
<p>The default character style bindings are:
<ul>
<li><code>&lt;em&gt;...&lt;/em&gt;</code>
- Emphasized. As default, this is the same as <code>&lt;i&gt;...&lt;/i&gt;</code> (Italic)
<li><code>&lt;strong&gt;...&lt;/strong&gt;</code>
- Strong. As default, this is the same as <code>&lt;bold&gt;...&lt;/bold&gt;</code> (bold).
<li><code>&lt;i&gt;...&lt;/i&gt;</code>
- Italic font style.
<li><code>&lt;b&gt;...&lt;/b&gt;</code>
- Bold font style.
<li><code>&lt;u&gt;...&lt;/u&gt;</code>
- Underlined font style.
<li><code>&lt;big&gt;...&lt;/big&gt;</code>
- A larger font size.
<li><code>&lt;small&gt;...&lt;/small&gt;</code>
- A smaller font size.
<li><code>&lt;code&gt;...&lt;/code&gt;</code>
- Indicates Code. As default, this is the same as <code>&lt;tt&gt;...&lt;/tt&gt;</code> (typewriter). For
larger junks of code, use the block-tag <code>pre.</code>
<li><code>&lt;tt&gt;...&lt;/tt&gt;</code>
- Typewriter font style.
<li><code>&lt;font&gt;...&lt;/font&gt;</code>
- Customizes the font size, family  and text color. The tag understands
the following  attributes:
<ul>
<li> <code>color</code>
- the text color, for example <code>color="red"</code> or <code>color="#FF0000".</code>
<li> <code>size</code>
- the logical size of the font. Logical sizes 1 to 7 are supported.
The value may either be absolute, for example
<code>size=3,</code> or relative like <code>size=-2.</code> In the latter case, the sizes
are simply added.
<li> <code>face</code>
- the family of the font, for example <code>face=times.</code>
</ul>
</ul>
<p>Special elements are:
<ul>
<li><code>&lt;img/&gt;</code>
- An image. The image name for the mime source
factory  is given in the source attribute, for example
<code>&lt;img src="qt.xpm"/&gt;</code> The image tag also
understands the attributes <code>width</code> and <code>height</code> that determine
the size of the image. If the pixmap does not fit to the specified
size, it will be scaled automatically ( by using <a href="qimage.html#239910">QImage::smoothScale</a>() ).
<p>The <code>align</code> attribute determines where the image is
placed. Per default, an image is placed inline, just like a
normal character. Specify <code>left</code> or <code>right</code> to place the
image at the respective side.
<li><code>&lt;hr/&gt;</code>
- A horizontal line
<li><code>&lt;br/&gt;</code>
- A line break
</ul>
<p>Other tags not in any of the above categories are:
<ul>
<li><code>&lt;nobr&gt;...&lt;/nobr&gt;</code>
- No break. Prevents word wrap.
</ul>
<p>In addition, rich text supports simple HTML tables. A table consists
of a set of rows where each row contains some number of cells. Cells
are either data cells or header cells, depending on their
content. Usually a cell fills one rectangle in the table grid. It
may, however, also span several rows, columns or both.
<p><ul>
<li><code>&lt;table&gt;...&lt;/table&gt;</code>
- A table definition.
The default table is frameless. Specify the boolean attribute
<code>border</code> in order to get a frame. Other attributes are:
<ul>
<li><code>bgcolor</code>
- The background color
<li> <code>width</code>
- The table width. This is either absolute in pixels or relative
in percent of the column width, for example <code>width=80%</code>
<li> <code>border</code>
- The width of the table border. The default is 0 (= no border).
<li> <code>cellspacing</code>
- Additional space around the table cells. The default is 2.
<li> <code>cellpadding</code>
- Additinal space around the contents of table cells. Default is 1.
</ul>
<li><code>&lt;tr&gt;...&lt;/tr&gt;</code>
- A table row. Can only be used within <code>table.</code> Understands the attribute
<ul>
<li><code>bgcolor</code>
- The background color
</ul>
<li><code>&lt;td&gt;...&lt;/td&gt;</code>
- A table data cell. Can only be used within <code>tr.</code> Understands the attributes
<ul>
<li><code>bgcolor</code>
- The background color
<li> <code>width</code>
- The cell width. This is either absolute in pixels or relative
in percent of the entire table width, for example <code>width=50%</code>
<li> <code>colspan</code>
- Defines how many columns this cell spans. The default is 1.
<li> <code>rowspan</code>
- Defines how many rows this cell spans. The default is 1.
<li> <code>align</code>
- Alignment, possible values are <code>left, right</code> and <code>center.</code> The
default is left-aligned.
</ul>
<li><code>&lt;th&gt;...&lt;/th&gt;</code>
- A table header cell. Like <code>td</code> but defaults to center-alignment
and a bold font.
</ul>

<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="0664aa"></a>QStyleSheet::QStyleSheet(<a href="qobject.html">QObject</a>*parent=0, constchar*name=0)</h3>
<p>Create a style sheet.  Like any <a href="qobject.html">QObject</a>, the created object will be
deleted when its parent destructs (if the child still exists then).
<p>By default, the style sheet has the tag definitions defined above.
<h3 class="fn"><a name="d4c965"></a>QStyleSheet::~QStyleSheet() <code>[virtual]</code></h3>
<p>Destructs the style sheet.  All styles inserted into the style sheet
will be deleted.
<h3 class="fn"><a href="qstring.html">QString</a><a name="e1e9e8"></a>QStyleSheet::convertFromPlainText(const<a href="qstring.html">QString</a>&amp;plain) <code>[static]</code></h3>
<p>Auxiliary function. Converts the plain text string <em>plain</em> to a
rich text formatted string while preserving its look.
<h3 class="fn">QStyleSheet*<a name="50ded7"></a>QStyleSheet::defaultSheet() <code>[static]</code></h3>
<p>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 also <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="qtextview.html">QTextView</a> and
<a href="qtextbrowser.html">QTextBrowser</a>.
<p>See also  <a href="#0aa4a1">setDefaultSheet</a>().
<h3 class="fn">void<a name="fcd933"></a>QStyleSheet::error(const<a href="qstring.html">QString</a>&amp;msg)const <code>[virtual]</code></h3>
<p>This virtual function is called when an error occurs when
processing rich text. Reimplement if 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 wrongly or
if tags are not closed properly.
<p><em>msg</em> is the error message.
<h3 class="fn"><a href="qstylesheetitem.html">QStyleSheetItem</a>*<a name="a6efac"></a>QStyleSheet::item(const<a href="qstring.html">QString</a>&amp;name)</h3>
<p>Returns the style with name <em>name</em> or 0 if there is no such style.
<h3 class="fn">const<a href="qstylesheetitem.html">QStyleSheetItem</a>*<a name="2749ea"></a>QStyleSheet::item(const<a href="qstring.html">QString</a>&amp;name)const</h3>
<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="58b86f"></a>QStyleSheet::mightBeRichText(const<a href="qstring.html">QString</a>&amp;text) <code>[static]</code></h3>
<p>Returns whether the string <em>text</em> is likely to be rich text
formatted.
<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. While the result may be correct for
most common cases, there is no guarantee.
<h3 class="fn">void<a name="9a27e3"></a>QStyleSheet::scaleFont(<a href="qfont.html">QFont</a>&amp;font, intlogicalSize)const <code>[virtual]</code></h3>
<p>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>Typical logical font sizes range from 1 to 7, with 1 being the smallest.
<p>See also  <a href="qstylesheetitem.html#2643ac">QStyleSheetItem::logicalFontSize</a>(), <a href="qstylesheetitem.html#cf7bf9">QStyleSheetItem::logicalFontSizeStep</a>() and <a href="qfont.html#fd77c1">QFont::setPointSize</a>().
<h3 class="fn">void<a name="0aa4a1"></a>QStyleSheet::setDefaultSheet(QStyleSheet*sheet) <code>[static]</code></h3>
<p>Sets the application-wide default style sheet, deleting any style
sheet previously set. The ownership is transferred.
<p>See also  <a href="#50ded7">defaultSheet</a>().
<h3 class="fn">QTextCustomItem*<a name="12755e"></a>QStyleSheet::tag(const<a href="qstring.html">QString</a>&amp;name, const<a href="qmap.html">QMap</a>&lt;<a href="qstring.html">QString</a>, <a href="qstring.html">QString</a>&gt;&amp;attr, const<a href="qstring.html">QString</a>&amp;context, const<a href="qmimesourcefactory.html">QMimeSourceFactory</a>&amp;factory, bool=FALSE)const <code>[virtual]</code></h3>
<p>Generates an internal object for tag named <em>name,</em> given the
attributes <em>attr,</em> and using additional information provided
by the mime source factory <em>factory</em> .
<p>This function should not (yet) be used in application code.
<h3 class="fn">void<a name="2c9c80"></a>QStyleSheet::insert(<a href="qstylesheetitem.html">QStyleSheetItem</a>*style)</h3>
<p>For internal use only.
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><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  2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>