A small displayable piece of rich text. More...
#include <qsimplerichtext.h>
This class encapsulates simple richt text usage where a string is interpreted as richt text and can be drawn. This is in particular useful if you want to display some rich text in a custom widget. A QStyleSheet is needed to actually understand and format rich text. Qt provides a default HTML-like style sheet but you may define custom style sheets.
Once created, the rich text object can be queried for its width(), height() and the actual width used (see widthUsed()). Most importantly, it can be drawn on any given QPainter with draw(). QSimpleRichText can also be used to implement hypertext or active text facilities by using anchorAt(). A hit test through inText() makes it possible to use simple rich text for text objects in editable drawing canvases.
Once constructed from a string, the contents cannot be changed, only resized. If the contents should change, just throw the rich text object away and make a new one with the new contents.
For large documents, see QTextView or QTextBrowser.
Constructs a QSimpleRichText from the rich text string text and the font fnt.
The font is used as basis for the text rendering. When using rich text rendering on a certain widget w, you would regularly specify the widget's font as shown in the following code example:
QSimpleRichText myrichtext( contents, mywidget->font() );
context is the optional context of the document. This becomes important if text contains relative references, for example within image tags. QSimpleRichText always uses the default mime source factory (see QMimeSourceFactory::defaultFactory() ) to resolve those references. The context will then be used to calculate the absolute path. See QMimeSourceFactory::makeAbsolute() for details.
Finally s is an optional style sheet. If it is 0, the default style sheet will be used (see QStyleSheet::defaultSheet() ).
Another, more complex constructor for QSimpleRichText that takes an additional mime source factory factory, a vertical break parameter verticalBreak, a link color linkColor and a bool linkUnderline.
The constructor is useful to create a QSimpleRichText object suitable for printing. Set verticalBreak to be the height of the contents area of the pages.
Destructs the document, freeing memory.
Adjusts the richt text document to a reasonable size.
See also setWidth().
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Returns the anchor at the requested position. The QPainter is needed for font size calculations. An empty string is returned if no anchor is specified for this certain position.
This function will be removed in 3.0.
Returns the anchor at the requested position. An empty string is returned if no anchor is specified for this certain position.
Returns the context of the rich text document. If no context has been specified in the constructor, a null string is returned.
Draws the formatted text with p, at position (x, y), clipped to clipRegion. Colors from the palette pal are used as needed, and if not 0, *paper is used as the background brush.
Note that the display code is highly optimized to reduce flicker, so passing a brush for paper is preferable to simply clearing the area to be painted and then calling this without a brush.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Draws the formatted text with p, at position (x, y), clipped to clipRegion. Colors from the cg are used as needed, and if not 0, *paper is used as the background brush.
Note that the display code is highly optimized to reduce flicker, so passing a brush for paper is preferable to simply clearing the area to be painted and then calling this without a brush.
This is a convenience function if there's no palette but just a color group available. If you have a palette, pass this instead of cg.
Returns the height of the document, in pixels.
See also setWidth().
Returns whether pos is within a text line of the document or not.
Sets the width of the document to w pixels, recalculating the layout as if it were to be drawn with p.
Passing a painter is useful when you intend to draw on devices other than the screen, like for example a QPrinter.
See also height() and adjustSize().
Sets the width of the document to w pixels.
See also height() and adjustSize().
Returns the set width of the document, in pixels.
See also widthUsed().
Returns the width in pixels that is actually used by the document. This can be smaller or wider than the set width.
It may be wider, for example, if the text contains images or non-breakable words that are already wider than the available space. It's smaller when the document only consists of lines that do not fill the width completely.
See also width().
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright İ 2000 Trolltech | Trademarks | Qt version 2.2.1
|