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
|
'\" t
.TH QStyleSheet 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QStyleSheet \- Collection of styles for rich text rendering and a generator of tags
.SH SYNOPSIS
\fC#include <ntqstylesheet.h>\fR
.PP
Inherits TQObject.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQStyleSheet\fR ( TQObject * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "virtual \fB~QStyleSheet\fR ()"
.br
.ti -1c
.BI "QStyleSheetItem * \fBitem\fR ( const TQString & name )"
.br
.ti -1c
.BI "const QStyleSheetItem * \fBitem\fR ( const TQString & name ) const"
.br
.ti -1c
.BI "virtual QTextCustomItem * \fBtag\fR ( const TQString & name, const QMap<TQString, TQString> & attr, const TQString & context, const QMimeSourceFactory & factory, bool emptyTag, QTextDocument * doc ) const"
.br
.ti -1c
.BI "virtual void \fBscaleFont\fR ( QFont & font, int logicalSize ) const"
.br
.ti -1c
.BI "virtual void \fBerror\fR ( const TQString & msg ) const"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "QStyleSheet * \fBdefaultSheet\fR ()"
.br
.ti -1c
.BI "void \fBsetDefaultSheet\fR ( QStyleSheet * sheet )"
.br
.ti -1c
.BI "TQString \fBescape\fR ( const TQString & plain )"
.br
.ti -1c
.BI "TQString \fBconvertFromPlainText\fR ( const TQString & plain, QStyleSheetItem::WhiteSpaceMode mode = QStyleSheetItem::WhiteSpacePre )"
.br
.ti -1c
.BI "bool \fBmightBeRichText\fR ( const TQString & text )"
.br
.in -1c
.SH DESCRIPTION
The QStyleSheet class is a collection of styles for rich text rendering and a generator of tags.
.PP
By creating QStyleSheetItem 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 QTextEdit or a QTextBrowser. However, QLabel, QWhatsThis and QMessageBox also support it, and other classes are likely to follow. With QSimpleRichText it is possible to use the rich text renderer for custom widgets as well.
.PP
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.
.PP
The structuring tags are <center>.nf
.TS
l - l. Structuring tags Notes A TQt rich text document. It understands the following attributes:
.TP
A top-level heading.
A sublevel heading.
A sub-sublevel heading.
Headings of lesser importance.
A left-aligned paragraph. Adjust the alignment with the
A centered paragraph.
An indented paragraph that is useful for quotes.
An unordered list. You can also pass a type argument to
define the bullet style. The default is
An ordered list. You can also pass a type argument to
define the enumeration label style. The default is
A list item. This tag can be used only within the context
of
A list of definitions, consisting of terms and descriptions.
A term in a list of definitions. This tag can be used only
in the context of
A description in a list of definitions. This tag can be
used only in the context of
For larger chunks of code. Whitespaces in the contents are
preserved. For small bits of code use the inline-style
.TE
.fi
</center>
.PP
Anchors and links are done with a single tag: <center>.nf
.TS
l - l. Anchor tags Notes An anchor or link.
.TP
A link is created by using an
.TE
.fi
</center>
.PP
The default character style bindings are <center>.nf
.TS
l - l. Style tags Notes Emphasized. By default this is the same as Strong. By default this is the same as Italic font style. Bold font style. Underlined font style. Strike out font style. A larger font size. A smaller font size. Subscripted text Superscripted text Indicates code. By default this is the same as Typewriter font style. Customizes the font size, family and text color. The tag understands the following attributes:
.TP
.TE
.fi
</center>
.PP
Special elements are: <center>.nf
.TS
l
-
l.
Special tags Notes
An image. The image name for the mime source factory is
given in the source attribute, for example
A horizontal line.
A line break.
.TE
.fi
</center>
.PP
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.
.PP
<center>.nf
.TS
l - l. Table tags Notes A table. Tables support the following attributes:
.TP
A table row. This is only valid within a A table header cell. Similar to A table data cell. This is only valid within a
.TE
.fi
</center>
.PP
See also Graphics Classes, Help System, and Text Related Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QStyleSheet::QStyleSheet ( TQObject * parent = 0, const char * name = 0 )"
Creates a style sheet called \fIname\fR, with parent \fIparent\fR. Like any TQObject it will be deleted when its parent is destroyed (if the child still exists).
.PP
By default the style sheet has the tag definitions defined above.
.SH "QStyleSheet::~QStyleSheet ()\fC [virtual]\fR"
Destroys the style sheet. All styles inserted into the style sheet will be deleted.
.SH "TQString QStyleSheet::convertFromPlainText ( const TQString & plain, QStyleSheetItem::WhiteSpaceMode mode = QStyleSheetItem::WhiteSpacePre )\fC [static]\fR"
Auxiliary function. Converts the plain text string \fIplain\fR to a rich text formatted paragraph while preserving most of its look.
.PP
\fImode\fR defines the whitespace mode. Possible values are QStyleSheetItem::WhiteSpacePre (no wrapping, all whitespaces preserved) and QStyleSheetItem::WhiteSpaceNormal (wrapping, simplified whitespaces).
.PP
See also escape().
.PP
Examples:
.)l action/application.cpp, application/application.cpp, and mdi/application.cpp.
.SH "QStyleSheet * QStyleSheet::defaultSheet ()\fC [static]\fR"
Returns the application-wide default style sheet. This style sheet is used by rich text rendering classes such as QSimpleRichText, QWhatsThis and QMessageBox to define the rendering style and available tags within rich text documents. It also serves as the initial style sheet for the more complex render widgets, QTextEdit and QTextBrowser.
.PP
See also setDefaultSheet().
.SH "void QStyleSheet::error ( const TQString & msg ) const\fC [virtual]\fR"
This virtual function is called when an error occurs when processing rich text. Reimplement it if you need to catch error messages.
.PP
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.
.PP
\fImsg\fR is the error message.
.SH "TQString QStyleSheet::escape ( const TQString & plain )\fC [static]\fR"
Auxiliary function. Converts the plain text string \fIplain\fR to a rich text formatted string with any HTML meta-characters escaped.
.PP
See also convertFromPlainText().
.SH "QStyleSheetItem * QStyleSheet::item ( const TQString & name )"
Returns the style called \fIname\fR or 0 if there is no such style.
.SH "const QStyleSheetItem * QStyleSheet::item ( const TQString & name ) const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the style called \fIname\fR or 0 if there is no such style (const version)
.SH "bool QStyleSheet::mightBeRichText ( const TQString & text )\fC [static]\fR"
Returns TRUE if the string \fItext\fR is likely to be rich text; otherwise returns FALSE.
.PP
This 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 common cases, there is no guarantee.
.SH "void QStyleSheet::scaleFont ( QFont & font, int logicalSize ) const\fC [virtual]\fR"
Scales the font \fIfont\fR to the appropriate physical point size corresponding to the logical font size \fIlogicalSize\fR.
.PP
When calling this function, \fIfont\fR has a point size corresponding to the logical font size 3.
.PP
Logical font sizes range from 1 to 7, with 1 being the smallest.
.PP
See also QStyleSheetItem::logicalFontSize(), QStyleSheetItem::logicalFontSizeStep(), and QFont::setPointSize().
.SH "void QStyleSheet::setDefaultSheet ( QStyleSheet * sheet )\fC [static]\fR"
Sets the application-wide default style sheet to \fIsheet\fR, deleting any style sheet previously set. The ownership is transferred to QStyleSheet.
.PP
See also defaultSheet().
.SH "QTextCustomItem * QStyleSheet::tag ( const TQString & name, const QMap<TQString, TQString> & attr, const TQString & context, const QMimeSourceFactory & factory, bool emptyTag, QTextDocument * doc ) const\fC [virtual]\fR"
\fBThis function is under development and is subject to change.\fR
.PP
Generates an internal object for the tag called \fIname\fR, given the attributes \fIattr\fR, and using additional information provided by the mime source factory \fIfactory\fR.
.PP
\fIcontext\fR 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. QSimpleRichText always uses the default mime source factory (see QMimeSourceFactory::defaultFactory()) to resolve these references. The context will then be used to calculate the absolute path. See QMimeSourceFactory::makeAbsolute() for details.
.PP
\fIemptyTag\fR and \fIdoc\fR are for internal use only.
.PP
This function should not be used in application code.
.SH "SEE ALSO"
.BR http://doc.trolltech.com/ntqstylesheet.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqstylesheet.3qt) and the Qt
version (3.3.8).
|