|Q3StyleSheet(QObject * parent = 0, const char * name = 0)|
|virtual void||error(const QString & msg) const|
|Q3StyleSheetItem *||item(const QString & name)|
|const Q3StyleSheetItem *||item(const QString & name) const|
|virtual void||scaleFont(QFont & font, int logicalSize) const|
- 29 public functions inherited from QObject
Static Public Members
|QString||convertFromPlainText(const QString & plain, Q3StyleSheetItem::WhiteSpaceMode mode = Q3StyleSheetItem::WhiteSpacePre)|
|QString||escape(const QString & plain)|
|bool||mightBeRichText(const QString & text)|
|void||setDefaultSheet(Q3StyleSheet * sheet)|
- 7 static public members inherited from QObject
Additional Inherited Members
- 1 property inherited from QObject
- 1 public slot inherited from QObject
- 1 signal inherited from QObject
- 8 protected functions inherited from QObject
The Q3StyleSheet class is a collection of styles for rich text rendering and a generator of tags.
By creating Q3StyleSheetItem 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.
The default Q3StyleSheet 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.
The structuring tags are
|A Qt rich text document. It understands the following attributes:|
|A top-level heading.|
|A sublevel heading.|
|A sub-sublevel heading.|
|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 |
|For larger chunks of code. Whitespaces in the contents are preserved. For small bits of code use the inline-style |
Anchors and links are done with a single tag:
|An anchor or link.|
The default character style bindings are
|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.|
|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:|
Special elements are:
|An image. The image name for the mime source factory is given in the source attribute, for example |
|A horizontal line.|
|A line break.|
|No break. Prevents word wrap.|
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.
|A table. Tables support the following attributes:|
|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 |
Member Function Documentation
Q3StyleSheet::Q3StyleSheet(QObject * parent = 0, const char * name = 0)
Creates a style sheet called name, with parent parent. Like any QObject it will be deleted when its parent is destroyed (if the child still exists).
By default the style sheet has the tag definitions defined above.
Destroys the style sheet. All styles inserted into the style sheet will be deleted.
[static] QString Q3StyleSheet::convertFromPlainText(const QString & plain, Q3StyleSheetItem::WhiteSpaceMode mode = Q3StyleSheetItem::WhiteSpacePre)
Auxiliary function. Converts the plain text string plain to a rich text formatted paragraph while preserving most of its look.
mode defines the whitespace mode. Possible values are
Q3StyleSheetItem::WhiteSpacePre (no wrapping, all whitespaces preserved) and Q3StyleSheetItem::WhiteSpaceNormal (wrapping, simplified whitespaces).
See also escape().
[static] Q3StyleSheet * Q3StyleSheet::defaultSheet()
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.
See also setDefaultSheet().
[virtual] void Q3StyleSheet::error(const QString & msg) const
This virtual function is called when an error occurs when processing rich text. Reimplement it if you need to catch error messages.
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.
msg is the error message.
Auxiliary function. Converts the plain text string plain to a rich text formatted string with any HTML meta-characters escaped.
See also convertFromPlainText().
Q3StyleSheetItem * Q3StyleSheet::item(const QString & name)
Returns the style called name or 0 if there is no such style.
const Q3StyleSheetItem * Q3StyleSheet::item(const QString & name) const
This is an overloaded function.
Returns the style called name or 0 if there is no such style (const version)
[static] bool Q3StyleSheet::mightBeRichText(const QString & text)
Returns true if the string text is likely to be rich text; otherwise returns false.
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.
[virtual] void Q3StyleSheet::scaleFont(QFont & font, int logicalSize) const
Scales the font font to the appropriate physical point size corresponding to the logical font size logicalSize.
When calling this function, font has a point size corresponding to the logical font size 3.
Logical font sizes range from 1 to 7, with 1 being the smallest.
[static] void Q3StyleSheet::setDefaultSheet(Q3StyleSheet * sheet)
Sets the application-wide default style sheet to sheet, deleting any style sheet previously set. The ownership is transferred to Q3StyleSheet.
See also defaultSheet().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.