⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qstylesheet.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
字号:
'\" t.TH QStyleSheet 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQStyleSheet \- Collection of styles for rich text rendering and a generator of tags.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 "virtual QTextCustomItem * \fBtag\fR ( const QString & name, const QMap<QString, QString> & attr, const QString & context, const QMimeSourceFactory & factory, bool emptyTag, QTextDocument * doc ) const".br.ti -1c.BI "virtual void \fBscaleFont\fR ( QFont & font, int logicalSize ) const".br.ti -1c.BI "virtual void \fBerror\fR ( const QString & msg ) const".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "QStyleSheet * \fBdefaultSheet\fR ()".br.ti -1c.BI "void \fBsetDefaultSheet\fR ( QStyleSheet * sheet )".br.ti -1c.BI "QString \fBescape\fR ( const QString & plain )".br.ti -1c.BI "QString \fBconvertFromPlainText\fR ( const QString & plain, QStyleSheetItem::WhiteSpaceMode mode = QStyleSheetItem::WhiteSpacePre )".br.ti -1c.BI "bool \fBmightBeRichText\fR ( const QString & text )".br.in -1c.SH DESCRIPTIONThe QStyleSheet class is a 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. 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..PPThe 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..PPThe structuring tags are.TP\fC<qt>\fR...\fC</qt>\fR - A Qt rich text document. It understands the following attributes:.TPtitle - The caption of the document. This attribute is easily accessible with QTextView::documentTitle()..TPtype - 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, which can be used to explain certain expressions in more detail 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..TPbgcolor - The background color, for example \fCbgcolor="yellow"\fR or \fCbgcolor="#0000FF"\fR..TPbackground - The background pixmap, for example \fCbackground="granit.xpm"\fR. The pixmap name will be resolved by a QMimeSourceFactory()..TPtext - The default text color, for example \fCtext="red"\fR..TPlink - The link color, for example \fClink="green"\fR..TP\fC<h1>...</h1>\fR - A top-level heading..TP\fC<h2>...</h2>\fR - A sublevel heading..TP\fC<h3>...</h3>\fR - A sub-sublevel heading..TP\fC<p>...</p>\fR - A left-aligned paragraph. Adjust the alignment with the \fCalign\fR attribute. Possible values are \fCleft\fR, \fCright\fR and \fCcenter\fR..TP\fC<center>...</center>\fR - A centered paragraph..TP\fC<blockquote>...</blockquote>\fR - An indented paragraph that is useful for quotes..TP\fC<ul>...</ul>\fR - An unordered 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>\fR...\fC</li>\fR - A list item. This tag can be used only 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 name attribute..PPThe default character style bindings are.TP\fC<em>...</em>\fR - Emphasized. By default this is the same as \fC<i>...</i>\fR (italic)..TP\fC<strong>...</strong>\fR - Strong. By default this is the same as \fC<b>...</b>\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. By 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:.TPcolor - The text color, for example \fCcolor="red"\fR or \fCcolor="#FF0000"\fR..TPsize - 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 (\fCsize=-2\fR). In the latter case the sizes are simply added..TPface - 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 the specified size it will be scaled automatically (by using QImage::smoothScale())..IPThe \fCalign\fR attribute determines where the image is placed. By 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 horizonal line..TP\fC<br>\fR - A line break..PPAnother tag not in any of the above cathegories is.TP\fC<nobr>...</nobr>\fR - No break. Prevents word wrap..PPIn 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..TP\fC<table>...</table>\fR - A table. Tables support the following attributes:.TPbgcolor - The background color..TPwidth - The table width. This is either an absolute pixel width or a relative percentage of the table's width, for example \fCwidth=80%\fR..TPborder - The width of the table border. The default is 0 (= no border)..TPcellspacing - Additional space around the table cells. The default is 2..TPcellpadding - Additional space around the contents of table cells. The default is 1..TP\fC<tr>...</tr>\fR - A table row. This is only valid within a \fCtable\fR. Rows support the following attribute:.TPbgcolor - The background color..TP\fC<th>...</th>\fR - A table header cell. Similar to \fCtd\fR, but defaults to center alignment and a bold font..TP\fC<td>...</td>\fR - A table data cell. This is only valid within a \fCtr\fR. Cells support the following attributes:.TPbgcolor - The background color..TPwidth - The cell width. This is either an absolute pixel width or a relative percentage of table's width, for example \fCwidth=50%\fR..TPcolspan - Specifies how many columns this cell spans. The default is 1..TProwspan - Specifies how many rows this cell spans. The default is 1..TPalign - Alignment; possible values are \fCleft\fR, \fCright\fR, and \fCcenter\fR. The default is left..PPSee also Graphics Classes, Help System and Text Related Classes..SH MEMBER FUNCTION DOCUMENTATION.SH "QStyleSheet::QStyleSheet ( QObject * parent = 0, const char * name = 0 )"Creates a style sheet with parent \fIparent\fR and name \fIname\fR. Like any QObject it will be deleted when its parent is destroyed (if the child still exists)..PPBy default the style sheet has the tag definitions defined above..SH "QStyleSheet::~QStyleSheet ()\fC [virtual]\fR"Destroys the style sheet. All styles inserted into the style sheet will be deleted..SH "QString QStyleSheet::convertFromPlainText ( const QString & plain, QStyleSheetItem::WhiteSpaceMode mode = QStyleSheetItem::WhiteSpacePre )\fC [static]\fR"Auxiliary function. Converts the plain text string \fIplain\fR to a rich text formatted paragraph while preserving its look..PP\fImode\fR defines the whitespace mode. Possible values are QStyleSheetItem::WhiteSpacePre (no wrapping, all whitespaces preserved) and QStyleSheetItem::WhiteSpaceNormal (wrapping, simplified whitespaces)..PPSee also escape()..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 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 QTextEdit 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 it 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 incorrectly, or if tags are not closed properly..PP\fImsg\fR is the error message..SH "QString QStyleSheet::escape ( const QString & plain )\fC [static]\fR"Auxiliary function. Converts the plain text string \fIplain\fR to a rich text formatted string with any HTML meta-characters escaped..PPSee also convertFromPlainText()..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"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns 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 TRUE if the string \fItext\fR is likely to be rich text; otherwise returns FALSE..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. Although 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..PPLogical 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 to \fIsheet\fR, deleting any style sheet previously set. The ownership is transferred to QStyleSheet..PPSee also defaultSheet()..SH "QTextCustomItem * QStyleSheet::tag ( const QString & name, const QMap<QString, QString> & attr, const QString & context, const QMimeSourceFactory & factory, bool emptyTag, QTextDocument * doc ) const\fC [virtual]\fR"\fBThis function is under development and is subject to change.\fR.PPGenerates an internal object for the tag called \fIname\fR, given the attributes \fIattr\fR, and using additional information provided by the mime source factory \fIfactory\fR..PP\fIcontext\fR is the optional context of the document, i.e. the path to look for relative links. This becomes important if the text contains relative references, for example within image tags. QSimpleRichText always uses the default mime source factory (see QMimeSourceFactory::defaultFactory()) to resolve these references. The context will then be used to calculate the absolute path. See QMimeSourceFactory::makeAbsolute() for details..PP\fIemptyTag\fR and \fIdoc\fR are for internal use only..PPThis function should not (yet) be used in application code..SH "SEE ALSO".BR http://doc.trolltech.com/qstylesheet.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qstylesheet.3qt) and the Qtversion (3.0.0).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -