📄 qstylesheet.3qt
字号:
.TH QStyleSheet 3qt "10 November 2000" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2000 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQStyleSheet \- A collection of styles for rich text rendering and a generator of tags.SH SYNOPSIS.br.PP\fC#include <qstylesheet.h>\fR.PPInherits QObject..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQStyleSheet\fR ( QObject * " "parent" "=0, const char * " "name" "=0 ) ".br.ti -1c.BI "virtual \fB~QStyleSheet\fR () ".br.ti -1c.BI "QStyleSheetItem* \fBitem\fR ( const QString & name ) ".br.ti -1c.BI "const QStyleSheetItem* \fBitem\fR ( const QString & name ) const".br.ti -1c.BI "void \fBinsert\fR ( QStyleSheetItem * item ) (internal)".br.ti -1c.BI "virtual QTextCustomItem* \fBtag\fR ( const QString & " "name" ", const QMap<QString, QString> & " "attr" ", const QString & " "context" ", const QMimeSourceFactory & " "factory" ", bool " "emptyTag" " = FALSE ) const".br.ti -1c.BI "virtual void \fBscaleFont\fR ( QFont & " "font" ", int logicalSize ) const".br.ti -1c.BI "virtual void \fBerror\fR ( const QString & ) const".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "QStyleSheet* \fBdefaultSheet\fR () ".br.ti -1c.BI "void \fBsetDefaultSheet\fR ( QStyleSheet * ) ".br.ti -1c.BI "QString \fBconvertFromPlainText\fR ( const QString & ) ".br.ti -1c.BI "bool \fBmightBeRichText\fR ( const QString & ) ".br.in -1c.SH DESCRIPTIONA collection of styles for rich text rendering and a generator of tags..PPBy 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. But also QLabel, QWhatsThis and QMessageBox support it for now, with others likely to follow. With QSimpleRichText it is possible to use the rich text renderer for custom widgets as well..PPThe default QStyleSheet object has the following style bindings, sorted by structuring bindings, anchors, character style bindings (i.e. inline styles), special elements like horizontal lines or images and other tags. In addition, rich text supports simple HTML tables..PPThe structuring tags are:.TP\fC<qt>...</qt>\fR - A Qt rich text document. It understands the following attributes.TP\fCtitle\fR - the caption of the document. This attribute is easily accessible with QTextView::documentTitle().TP\fCtype\fR - The type of the document. The default type is \fCpage\fR . It indicates that the document is displayed in a page of its own. Another style is \fCdetail.\fR It can be used to explain certain expressions more detailed in a few sentences. The 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 \fC<qt type="detail" >...</qt>\fR.TP\fCbgcolor\fR - The background color, for example \fCbgcolor="yellow"\fR or \fCbgcolor="#0000FF"\fR.TP\fCbackground\fR - The background pixmap, for example \fCbackground="granit.xpm".\fR The pixmap name will be resolved by a QMimeSourceFactory()..TP\fCtext\fR - The default text color, for example \fCtext="red"\fR.TP\fClink\fR - The link color, for example \fClink="green"\fR.TP\fC<h1>...</h1>\fR - A top-level heading..TP\fC<h2>...</h2>\fR - A sub-level heading..TP\fC<h3>...</h3>\fR - A sub-sub-level heading..TP\fC<p>...</p>\fR - A left-aligned paragraph. Adjust the alignment with the \fCalign\fR attribute. Possible values are \fCleft, right\fR and \fCcenter.\fR.TP\fC<center>...</center>\fR - A centered paragraph..TP\fC<blockquote>...</blockquote>\fR - An indented paragraph, useful for quotes..TP\fC<ul>...</ul>\fR - An un-ordered list. You can also pass a type argument to define the bullet style. The default is \fCtype=disc,\fR other types are \fCcircle\fR and \fCsquare.\fR.TP\fC<ol>...</ol>\fR - An ordered list. You can also pass a type argument to define the enumeration label style. The default is \fCtype="1",\fR other types are \fC"a"\fR and \fC"A".\fR.TP\fC<li>...</li>\fR - A list item. This tag can only be used within the context of \fCol\fR or \fCul.\fR.TP\fC<pre>...</pre>\fR - For larger junks of code. Whitespaces in the contents are preserved. For small bits of code, use the inline-style \fCcode.\fR.PPAnchors and links are done with a single tag:.TP\fC<a>...</a>\fR - An anchor or link. The reference target is defined in the \fChref\fR attribute of the tag as in \fC<a href="target.qml">...</a>.\fR You can also specify an additional anchor within the specified target document, for example \fC<a href="target.qml#123">...</a>.\fR If \fCa\fR is meant to be an anchor, the reference source is given in the \fCname\fR attribute..PPThe default character style bindings are:.TP\fC<em>...</em>\fR - Emphasized. As default, this is the same as \fC<i>...</i>\fR (Italic).TP\fC<strong>...</strong>\fR - Strong. As default, this is the same as \fC<bold>...</bold>\fR (bold)..TP\fC<i>...</i>\fR - Italic font style..TP\fC<b>...</b>\fR - Bold font style..TP\fC<u>...</u>\fR - Underlined font style..TP\fC<big>...</big>\fR - A larger font size..TP\fC<small>...</small>\fR - A smaller font size..TP\fC<code>...</code>\fR - Indicates Code. As default, this is the same as \fC<tt>...</tt>\fR (typewriter). For larger junks of code, use the block-tag \fCpre.\fR.TP\fC<tt>...</tt>\fR - Typewriter font style..TP\fC<font>...</font>\fR - Customizes the font size, family and text color. The tag understands the following attributes:.TP\fCcolor\fR - the text color, for example \fCcolor="red"\fR or \fCcolor="#FF0000".\fR.TP\fCsize\fR - the logical size of the font. Logical sizes 1 to 7 are supported. The value may either be absolute, for example \fCsize=3,\fR or relative like \fCsize=-2.\fR In the latter case, the sizes are simply added..TP\fCface\fR - the family of the font, for example \fCface=times.\fR.PPSpecial elements are:.TP\fC<img/>\fR - An image. The image name for the mime source factory is given in the source attribute, for example \fC<img src="qt.xpm"/>\fR The image tag also understands the attributes \fCwidth\fR and \fCheight\fR that determine the size of the image. If the pixmap does not fit to the specified size, it will be scaled automatically ( by using QImage::smoothScale() )..IPThe \fCalign\fR attribute determines where the image is placed. Per default, an image is placed inline, just like a normal character. Specify \fCleft\fR or \fCright\fR to place the image at the respective side..TP\fC<hr/>\fR - A horizontal line.TP\fC<br/>\fR - A line break.PPOther tags not in any of the above categories are:.TP\fC<nobr>...</nobr>\fR - No break. Prevents word wrap..PPIn addition, rich text supports simple HTML tables. A table consists of a set of rows where each row contains some number of cells. Cells are either data cells or header cells, depending on their content. Usually a cell fills one rectangle in the table grid. It may, however, also span several rows, columns or both..TP\fC<table>...</table>\fR - A table definition. The default table is frameless. Specify the boolean attribute \fCborder\fR in order to get a frame. Other attributes are:.TP\fCbgcolor\fR - The background color.TP\fCwidth\fR - The table width. This is either absolute in pixels or relative in percent of the column width, for example \fCwidth=80%\fR.TP\fCborder\fR - The width of the table border. The default is 0 (= no border)..TP\fCcellspacing\fR - Additional space around the table cells. The default is 2..TP\fCcellpadding\fR - Additinal space around the contents of table cells. Default is 1..TP\fC<tr>...</tr>\fR - A table row. Can only be used within \fCtable.\fR Understands the attribute.TP\fCbgcolor\fR - The background color.TP\fC<td>...</td>\fR - A table data cell. Can only be used within \fCtr.\fR Understands the attributes.TP\fCbgcolor\fR - The background color.TP\fCwidth\fR - The cell width. This is either absolute in pixels or relative in percent of the entire table width, for example \fCwidth=50%\fR.TP\fCcolspan\fR - Defines how many columns this cell spans. The default is 1..TP\fCrowspan\fR - Defines how many rows this cell spans. The default is 1..TP\fCalign\fR - Alignment, possible values are \fCleft, right\fR and \fCcenter.\fR The default is left-aligned..TP\fC<th>...</th>\fR - A table header cell. Like \fCtd\fR but defaults to center-alignment and a bold font..SH MEMBER FUNCTION DOCUMENTATION.SH "QStyleSheet::QStyleSheet ( QObject * parent=0, const char * name=0 )"Create a style sheet. Like any QObject, the created object will be deleted when its parent destructs (if the child still exists then)..PPBy default, the style sheet has the tag definitions defined above..SH "QStyleSheet::~QStyleSheet () \fC[virtual]\fR"Destructs the style sheet. All styles inserted into the style sheet will be deleted..SH "QString QStyleSheet::convertFromPlainText ( const QString & plain ) \fC[static]\fR"Auxiliary function. Converts the plain text string \fIplain\fR to a rich text formatted string while preserving its look..SH "QStyleSheet* QStyleSheet::defaultSheet () \fC[static]\fR"Returns the application-wide default style sheet.This style sheet is used by rich text rendering classes such as QSimpleRichText, QWhatsThis and also QMessageBox to define the rendering style and available tags within rich text documents. It serves also as initial style sheet for the more complex render widgets QTextView and QTextBrowser..PPSee also setDefaultSheet()..SH "void QStyleSheet::error ( const QString & msg ) const \fC[virtual]\fR"This virtual function is called when an error occurs when processing rich text. Reimplement if if you need to catch error messages..PPErrors might occur if some rich text strings contain tags that are not understood by the stylesheet, if some tags are nested wrongly or if tags are not closed properly..PP\fImsg\fR is the error message..SH "QStyleSheetItem* QStyleSheet::item ( const QString & name )"Returns the style with name \fIname\fR or 0 if there is no such style..SH "const QStyleSheetItem* QStyleSheet::item ( const QString & name ) const"Returns the style with name \fIname\fR or 0 if there is no such style (const version)..SH "bool QStyleSheet::mightBeRichText ( const QString & text ) \fC[static]\fR"Returns whether the string \fItext\fR is likely to be rich text formatted..PPNote: The 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. While the result may be correct for most common cases, there is no guarantee..SH "void QStyleSheet::scaleFont ( QFont & font, int logicalSize ) const \fC[virtual]\fR"Scales the font \fIfont\fR to the appropriate physical point size corresponding to the logical font size \fIlogicalSize.\fR.PPWhen calling this function, \fIfont\fR has a point size corresponding to the logical font size 3..PPTypical logical font sizes range from 1 to 7, with 1 being the smallest..PPSee also QStyleSheetItem::logicalFontSize(), QStyleSheetItem::logicalFontSizeStep() and QFont::setPointSize()..SH "void QStyleSheet::setDefaultSheet ( QStyleSheet * sheet ) \fC[static]\fR"Sets the application-wide default style sheet, deleting any style sheet previously set. The ownership is transferred..PPSee also defaultSheet()..SH "QTextCustomItem* QStyleSheet::tag ( const QString & name, const QMap<QString, QString> & attr, const QString & context, const QMimeSourceFactory & factory, bool = FALSE ) const \fC[virtual]\fR"Generates an internal object for tag named \fIname,\fR given the attributes \fIattr,\fR and using additional information provided by the mime source factory \fIfactory\fR ..PPThis function should not (yet) be used in application code..SH "void QStyleSheet::insert ( QStyleSheetItem * style )"For internal use only..SH "SEE ALSO".BR http://doc.trolltech.com/qstylesheet.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -