1QSimpleRichText(3qt)                                      QSimpleRichText(3qt)
2
3
4

NAME

6       QSimpleRichText - Small displayable piece of rich text
7

SYNOPSIS

9       #include <qsimplerichtext.h>
10
11   Public Members
12       QSimpleRichText ( const QString & text, const QFont & fnt, const
13           QString & context = QString::null, const QStyleSheet * sheet = 0 )
14       QSimpleRichText ( const QString & text, const QFont & fnt, const
15           QString & context, const QStyleSheet * sheet, const
16           QMimeSourceFactory * factory, int pageBreak = -1, const QColor &
17           linkColor = Qt::blue, bool linkUnderline = TRUE )
18       ~QSimpleRichText ()
19       void setWidth ( int w )
20       void setWidth ( QPainter * p, int w )
21       void setDefaultFont ( const QFont & f )
22       int width () const
23       int widthUsed () const
24       int height () const
25       void adjustSize ()
26       void draw ( QPainter * p, int x, int y, const QRect & clipRect, const
27           QColorGroup & cg, const QBrush * paper = 0 ) const
28       void draw ( QPainter * p, int x, int y, const QRegion & clipRegion,
29           const QColorGroup & cg, const QBrush * paper = 0 ) const
30           (obsolete)
31       QString context () const
32       QString anchorAt ( const QPoint & pos ) const
33       bool inText ( const QPoint & pos ) const
34

DESCRIPTION

36       The QSimpleRichText class provides a small displayable piece of rich
37       text.
38
39       This class encapsulates simple rich text usage in which a string is
40       interpreted as rich text and can be drawn. This is particularly useful
41       if you want to display some rich text in a custom widget. A QStyleSheet
42       is needed to interpret the tags and format the rich text. Qt provides a
43       default HTML-like style sheet, but you may define custom style sheets.
44
45       Once created, the rich text object can be queried for its width(),
46       height(), and the actual width used (see widthUsed()). Most
47       importantly, it can be drawn on any given QPainter with draw().
48       QSimpleRichText can also be used to implement hypertext or active text
49       facilities by using anchorAt(). A hit test through inText() makes it
50       possible to use simple rich text for text objects in editable drawing
51       canvases.
52
53       Once constructed from a string the contents cannot be changed, only
54       resized. If the contents change, just throw the rich text object away
55       and make a new one with the new contents.
56
57       For large documents use QTextEdit or QTextBrowser. For very small items
58       of rich text you can use a QLabel.
59
60       If you are using QSimpleRichText to print in high resolution you should
61       call setWidth(QPainter, int) so that the content will be laid out
62       properly on the page.
63
64       See also Text Related Classes.
65

MEMBER FUNCTION DOCUMENTATION

QSimpleRichText::QSimpleRichText ( const QString & text, const QFont & fnt,

68       const QString & context = QString::null, const QStyleSheet * sheet = 0
69       )
70       Constructs a QSimpleRichText from the rich text string text and the
71       font fnt.
72
73       The font is used as a basis for the text rendering. When using rich
74       text rendering on a widget w, you would normally specify the widget's
75       font, for example:
76
77           QSimpleRichText myrichtext( contents, mywidget->font() );
78
79       context is the optional context of the rich text object. This becomes
80       important if text contains relative references, for example within
81       image tags. QSimpleRichText always uses the default mime source factory
82       (see QMimeSourceFactory::defaultFactory()) to resolve those references.
83       The context will then be used to calculate the absolute path. See
84       QMimeSourceFactory::makeAbsolute() for details.
85
86       The sheet is an optional style sheet. If it is 0, the default style
87       sheet will be used (see QStyleSheet::defaultSheet()).
88

QSimpleRichText::QSimpleRichText ( const QString & text, const QFont & fnt,

90       const QString & context, const QStyleSheet * sheet, const
91       QMimeSourceFactory * factory, int pageBreak = -1, const QColor &
92       linkColor = Qt::blue, bool linkUnderline = TRUE )
93       Constructs a QSimpleRichText from the rich text string text and the
94       font fnt.
95
96       This is a slightly more complex constructor for QSimpleRichText that
97       takes an additional mime source factory factory, a page break parameter
98       pageBreak and a bool linkUnderline. linkColor is only provided for
99       compatibility, but has no effect, as QColorGroup's QColorGroup::link()
100       color is used now.
101
102       context is the optional context of the rich text object. This becomes
103       important if text contains relative references, for example within
104       image tags. QSimpleRichText always uses the default mime source factory
105       (see QMimeSourceFactory::defaultFactory()) to resolve those references.
106       The context will then be used to calculate the absolute path. See
107       QMimeSourceFactory::makeAbsolute() for details.
108
109       The sheet is an optional style sheet. If it is 0, the default style
110       sheet will be used (see QStyleSheet::defaultSheet()).
111
112       This constructor is useful for creating a QSimpleRichText object
113       suitable for printing. Set pageBreak to be the height of the contents
114       area of the pages.
115

QSimpleRichText::~QSimpleRichText ()

117       Destroys the rich text object, freeing memory.
118

void QSimpleRichText::adjustSize ()

120       Adjusts the richt text object to a reasonable size.
121
122       See also setWidth().
123

QString QSimpleRichText::anchorAt ( const QPoint & pos ) const

125       Returns the anchor at the requested position, pos. An empty string is
126       returned if no anchor is specified for this position.
127

QString QSimpleRichText::context () const

129       Returns the context of the rich text object. If no context has been
130       specified in the constructor, a null string is returned. The context is
131       the path to use to look up relative links, such as image tags and
132       anchor references.
133

void QSimpleRichText::draw ( QPainter * p, int x, int y, const QRect &

135       clipRect, const QColorGroup & cg, const QBrush * paper = 0 ) const
136       Draws the formatted text with painter p, at position (x, y), clipped to
137       clipRect. The clipping rectangle is given in the rich text object's
138       coordinates translated by (x, y). Passing an null rectangle results in
139       no clipping. Colors from the color group cg are used as needed, and if
140       not 0, *paper is used as the background brush.
141
142       Note that the display code is highly optimized to reduce flicker, so
143       passing a brush for paper is preferable to simply clearing the area to
144       be painted and then calling this without a brush.
145
146       Examples:
147

void QSimpleRichText::draw ( QPainter * p, int x, int y, const QRegion &

149       clipRegion, const QColorGroup & cg, const QBrush * paper = 0 ) const
150       This function is obsolete. It is provided to keep old source working.
151       We strongly advise against using it in new code.
152
153       Use the version with clipRect instead. The region version has problems
154       with larger documents on some platforms (on X11 regions internally are
155       represented with 16bit coordinates).
156

int QSimpleRichText::height () const

158       Returns the height of the rich text object in pixels.
159
160       See also setWidth().
161
162       Examples:
163

bool QSimpleRichText::inText ( const QPoint & pos ) const

165       Returns TRUE if pos is within a text line of the rich text object;
166       otherwise returns FALSE.
167

void QSimpleRichText::setDefaultFont ( const QFont & f )

169       Sets the default font for the rich text object to f
170

void QSimpleRichText::setWidth ( QPainter * p, int w )

172       Sets the width of the rich text object to w pixels, recalculating the
173       layout as if it were to be drawn with painter p.
174
175       Passing a painter is useful when you intend drawing on devices other
176       than the screen, for example a QPrinter.
177
178       See also height() and adjustSize().
179
180       Examples:
181

void QSimpleRichText::setWidth ( int w )

183       This is an overloaded member function, provided for convenience. It
184       behaves essentially like the above function.
185
186       Sets the width of the rich text object to w pixels.
187
188       See also height() and adjustSize().
189

int QSimpleRichText::width () const

191       Returns the set width of the rich text object in pixels.
192
193       See also widthUsed().
194

int QSimpleRichText::widthUsed () const

196       Returns the width in pixels that is actually used by the rich text
197       object. This can be smaller or wider than the set width.
198
199       It may be wider, for example, if the text contains images or non-
200       breakable words that are already wider than the available space. It's
201       smaller when the object only consists of lines that do not fill the
202       width completely.
203
204       See also width().
205
206

SEE ALSO

208       http://doc.trolltech.com/qsimplerichtext.html
209       http://www.trolltech.com/faq/tech.html
210
212       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
213       license file included in the distribution for a complete license
214       statement.
215

AUTHOR

217       Generated automatically from the source code.
218

BUGS

220       If you find a bug in Qt, please report it as described in
221       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
222       help you. Thank you.
223
224       The definitive Qt documentation is provided in HTML format; it is
225       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
226       web browser. This man page is provided as a convenience for those users
227       who prefer man pages, although this format is not officially supported
228       by Trolltech.
229
230       If you find errors in this manual page, please report them to qt-
231       bugs@trolltech.com.  Please include the name of the manual page
232       (qsimplerichtext.3qt) and the Qt version (3.3.8).
233
234
235
236Trolltech AS                    2 February 2007           QSimpleRichText(3qt)
Impressum