Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The TQSimpleRichText class provides a small displayable piece of rich text. More...
#include <qsimplerichtext.h>
This class encapsulates simple rich text usage in which a string is interpreted as rich text and can be drawn. This is particularly useful if you want to display some rich text in a custom widget. A TQStyleSheet is needed to interpret the tags and format the rich text. TQt 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 TQPainter with draw(). TQSimpleRichText 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 change, just throw the rich text object away and make a new one with the new contents.
For large documents use TQTextEdit or TQTextBrowser. For very small items of rich text you can use a TQLabel.
If you are using TQSimpleRichText to print in high resolution you should call setWidth(TQPainter, int) so that the content will be laid out properly on the page.
See also Text Related Classes.
The font is used as a basis for the text rendering. When using rich text rendering on a widget w, you would normally specify the widget's font, for example:
TQSimpleRichText myrichtext( contents, mywidget->font() );
context is the optional context of the rich text object. This becomes important if text contains relative references, for example within image tags. TQSimpleRichText always uses the default mime source factory (see TQMimeSourceFactory::defaultFactory()) to resolve those references. The context will then be used to calculate the absolute path. See TQMimeSourceFactory::makeAbsolute() for details.
The sheet is an optional style sheet. If it is 0, the default style sheet will be used (see TQStyleSheet::defaultSheet()).
This is a slightly more complex constructor for TQSimpleRichText that takes an additional mime source factory factory, a page break parameter pageBreak and a bool linkUnderline. linkColor is only provided for compatibility, but has no effect, as TQColorGroup's TQColorGroup::link() color is used now.
context is the optional context of the rich text object. This becomes important if text contains relative references, for example within image tags. TQSimpleRichText always uses the default mime source factory (see TQMimeSourceFactory::defaultFactory()) to resolve those references. The context will then be used to calculate the absolute path. See TQMimeSourceFactory::makeAbsolute() for details.
The sheet is an optional style sheet. If it is 0, the default style sheet will be used (see TQStyleSheet::defaultSheet()).
This constructor is useful for creating a TQSimpleRichText object suitable for printing. Set pageBreak to be the height of the contents area of the pages.
See also setWidth().
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.
Examples: action/application.cpp, application/application.cpp, helpviewer/helpwindow.cpp, and mdi/application.cpp.
This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.
Use the version with clipRect instead. The region version has problems with larger documents on some platforms (on X11 regions internally are represented with 16bit coordinates).
See also setWidth().
Examples: action/application.cpp, application/application.cpp, helpviewer/helpwindow.cpp, and mdi/application.cpp.
Passing a painter is useful when you intend drawing on devices other than the screen, for example a TQPrinter.
See also height() and adjustSize().
Examples: action/application.cpp, application/application.cpp, helpviewer/helpwindow.cpp, and mdi/application.cpp.
Sets the width of the rich text object to w pixels.
See also height() and adjustSize().
See also widthUsed().
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 object only consists of lines that do not fill the width completely.
See also width().
This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.
Copyright © 2007 Trolltech | Trademarks | TQt 3.3.8
|