#include <qstylesheet.h>
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 QTextView 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 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.
The structuring tags are Structuring tags Notes {<qt>}...{</qt>} A Qt rich text document. It understands the following attributes: title -- The caption of the document. This attribute is easily accessible with QTextView::documentTitle(). type -- The type of the document. The default type is page. It indicates that the document is displayed in a page of its own. Another style is detail, which can be used to explain certain expressions in more detail in a few sentences. For detail, QTextBrowser will then keep the current page and display the new document in a small popup similar to QWhatsThis. Note that links will not work in documents with {<qt type="detail">...</qt>}. bgcolor -- The background color, for example bgcolor="yellow" or bgcolor="#0000FF". background -- The background pixmap, for example background="granite.xpm". The pixmap name will be resolved by a QMimeSourceFactory(). text -- The default text color, for example text="red". link -- The link color, for example link="green". {
} A top-level heading. {
} A sublevel heading. {
} A sub-sublevel heading. {
...} A left-aligned paragraph. Adjust the alignment with the align attribute. Possible values are left, right and center. {
{{<blockquote>...}{</blockquote>} An indented paragraph that is useful for quotes. {type=disc; other types are circle and square. {type="1"; other types are "a" and "A". {...} 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
code.
Anchors and links are done with a single tag: Anchor tags Notes {...} An anchor or link. A link is created by using an href attribute, for example
{Link Text}. Links to targets within a document are achieved in the same way as for HTML, e.g.
{Link Text}. A target is created by using a name attribute, for example
{
}.
The default character style bindings are Style tags Notes {...} Emphasized. By default this is the same as {...} (italic). {...} Strong. By default this is the same as {...} (bold). {...} Italic font style. {...} Bold font style. {<u>...</u>} Underlined font style. {<s>...</s>} Strike out font style. {<big>...</big>} A larger font size. {...} A smaller font size. {...} Indicates code. By default this is the same as {...} (typewriter). For larger junks of code use the block-tag {<}{pre>}. {...} Typewriter font style. {<font>...</font>} Customizes the font size, family and text color. The tag understands the following attributes: color -- The text color, for example color="red" or color="#FF0000". size -- The logical size of the font. Logical sizes 1 to 7 are supported. The value may either be absolute (for example, size=3) or relative (size=-2). In the latter case the sizes are simply added. face -- The family of the font, for example face=times.
Special elements are: Special tags Notes {} An image. The image name for the mime source factory is given in the source attribute, for example {
width and height that determine the size of the image. If the pixmap does not fit the specified size it will be scaled automatically (by using QImage::smoothScale()). align attribute determines where the image is placed. By default, an image is placed inline just like a normal character. Specify left or right to place the image at the respective side. {{{<nobr>...</nobr>} 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.
Table tags Notes {
} A table. Tables support the following attributes: bgcolor -- The background color. width -- The table width. This is either an absolute pixel width or a relative percentage of the table's width, for example width=80%. border -- The width of the table border. The default is 0 (= no border). cellspacing -- Additional space around the table cells. The default is 2. cellpadding -- Additional space around the contents of table cells. The default is 1. {
...} A table row. This is only valid within a table. Rows support the following attribute: bgcolor -- The background color. {
...} A table header cell. Similar to td, but defaults to center alignment and a bold font. {
...} A table data cell. This is only valid within a tr. Cells support the following attributes: bgcolor -- The background color. width -- The cell width. This is either an absolute pixel width or a relative percentage of table's width, for example width=50%. colspan -- Specifies how many columns this cell spans. The default is 1. rowspan -- Specifies how many rows this cell spans. The default is 1. align -- Alignment; possible values are left, right, and center. The default is left.
1.4.2