返回介绍

QStyleSheetItem Class

发布于 2019-10-04 15:03:11 字数 18717 浏览 987 评论 0 收藏 0

The QStyleSheetItem class provides an encapsulation of a set of text styles. More...

#include <qstylesheet.h>

Inherits Qt.

List of all member functions.

Public Members

  • QStyleSheetItem ( QStyleSheet*parent, constQString&name )
  • QStyleSheetItem ( constQStyleSheetItem&other )
  • ~QStyleSheetItem ()
  • QString name () const
  • QStyleSheet * styleSheet ()
  • const QStyleSheet * styleSheet () const
  • enum DisplayMode { DisplayBlock, DisplayInline, DisplayListItem, DisplayNone }
  • DisplayMode displayMode () const
  • void setDisplayMode ( DisplayModem )
  • int alignment () const
  • void setAlignment ( intf )
  • enum VerticalAlignment { VAlignBaseline, VAlignSub, VAlignSuper }
  • VerticalAlignment verticalAlignment () const
  • void setVerticalAlignment ( VerticalAlignmentvalign )
  • int fontWeight () const
  • void setFontWeight ( intw )
  • int logicalFontSize () const
  • void setLogicalFontSize ( ints )
  • int logicalFontSizeStep () const
  • void setLogicalFontSizeStep ( ints )
  • int fontSize () const
  • void setFontSize ( ints )
  • QString fontFamily () const
  • void setFontFamily ( constQString&fam )
  • int numberOfColumns () const (obsolete)
  • void setNumberOfColumns ( intncols ) (obsolete)
  • QColor color () const
  • void setColor ( constQColor&c )
  • bool fontItalic () const
  • void setFontItalic ( boolitalic )
  • bool definesFontItalic () const
  • bool fontUnderline () const
  • void setFontUnderline ( boolunderline )
  • bool definesFontUnderline () const
  • bool fontStrikeOut () const
  • void setFontStrikeOut ( boolstrikeOut )
  • bool definesFontStrikeOut () const
  • bool isAnchor () const
  • void setAnchor ( boolanc )
  • enum WhiteSpaceMode { WhiteSpaceNormal, WhiteSpacePre, WhiteSpaceNoWrap }
  • WhiteSpaceMode whiteSpaceMode () const
  • void setWhiteSpaceMode ( WhiteSpaceModem )
  • enum Margin { MarginLeft, MarginRight, MarginTop, MarginBottom, MarginFirstLine, MarginAll, MarginVertical, MarginHorizontal }
  • int margin ( Marginm ) const
  • void setMargin ( Marginm, intv )
  • enum ListStyle { ListDisc, ListCircle, ListSquare, ListDecimal, ListLowerAlpha, ListUpperAlpha }
  • ListStyle listStyle () const
  • void setListStyle ( ListStyles )
  • QString contexts () const
  • void setContexts ( constQString&c )
  • bool allowedInContext ( constQStyleSheetItem*s ) const
  • bool selfNesting () const
  • void setSelfNesting ( boolnesting )
  • void setLineSpacing ( intls )
  • int lineSpacing () const (obsolete)

Detailed Description

The QStyleSheetItem class provides an encapsulation of a set of text styles.

A style sheet item consists of a name and a set of attributes that specifiy its font, color, etc. When used in a style sheet (see styleSheet()), items define the name() of a rich text tag and the display property changes associated with it.

The display mode attribute indicates whether the item is a block, an inline element or a list element; see setDisplayMode(). The treatment of whitespace is controlled by the white space mode; see setWhiteSpaceMode(). An item's margins are set with setMargin(), In the case of list items, the list style is set with setListStyle(). An item may be a hypertext link anchor; see setAnchor(). Other attributes are set with setAlignment(), setVerticalAlignment(), setFontFamily(), setFontSize(), setFontWeight(), setFontItalic(), setFontUnderline(), setFontStrikeOut and setColor().

See also Text Related Classes.


Member Type Documentation

QStyleSheetItem::DisplayMode

This enum type defines the way adjacent elements are displayed.

  • QStyleSheetItem::DisplayBlock - elements are displayed as a rectangular block (e.g. <p>...</p>).
  • QStyleSheetItem::DisplayInline - elements are displayed in a horizontally flowing sequence (e.g. <em>...</em>).
  • QStyleSheetItem::DisplayListItem - elements are displayed in a vertical sequence (e.g. <li>...</li>).
  • QStyleSheetItem::DisplayNone - elements are not displayed at all.

QStyleSheetItem::ListStyle

This enum type defines how the items in a list are prefixed when displayed.

  • QStyleSheetItem::ListDisc - a filled circle (i.e. a bullet)
  • QStyleSheetItem::ListCircle - an unfilled circle
  • QStyleSheetItem::ListSquare - a filled square
  • QStyleSheetItem::ListDecimal - an integer in base 10: 1, 2, 3, ...
  • QStyleSheetItem::ListLowerAlpha - a lowercase letter: a, b, c, ...
  • QStyleSheetItem::ListUpperAlpha - an uppercase letter: A, B, C, ...

QStyleSheetItem::Margin

  • QStyleSheetItem::MarginLeft - left margin
  • QStyleSheetItem::MarginRight - right margin
  • QStyleSheetItem::MarginTop - top margin
  • QStyleSheetItem::MarginBottom - bottom margin
  • QStyleSheetItem::MarginAll - all margins (left, right, top and bottom)
  • QStyleSheetItem::MarginVertical - top and bottom margins
  • QStyleSheetItem::MarginHorizontal - left and right margins
  • QStyleSheetItem::MarginFirstLine - margin (indentation) of the first line of a paragarph (in addition to the MarginLeft of the paragraph)

QStyleSheetItem::VerticalAlignment

This enum type defines the way elements are aligned vertically. This is only supported for text elements.

  • QStyleSheetItem::VAlignBaseline - align the baseline of the element (or the bottom, if the element doesn't have a baseline) with the baseline of the parent
  • QStyleSheetItem::VAlignSub - subscript the element
  • QStyleSheetItem::VAlignSuper - superscript the element

QStyleSheetItem::WhiteSpaceMode

This enum defines the ways in which QStyleSheet can treat whitespace.

  • QStyleSheetItem::WhiteSpaceNormal - any sequence of whitespace (including line-breaks) is equivalent to a single space.
  • QStyleSheetItem::WhiteSpacePre - whitespace must be output exactly as given in the input.
  • QStyleSheetItem::WhiteSpaceNoWrap - multiple spaces are collapsed as with WhiteSpaceNormal, but no automatic line-breaks occur. To break lines manually, use the <br> tag.


Member Function Documentation

QStyleSheetItem::QStyleSheetItem ( QStyleSheet*parent, constQString&name )

Constructs a new style called name for the stylesheet parent.

All properties in QStyleSheetItem are initially in the "do not change" state, except display mode, which defaults to DisplayInline.

QStyleSheetItem::QStyleSheetItem ( constQStyleSheetItem&other )

Copy constructor. Constructs a copy of other that is not bound to any style sheet.

QStyleSheetItem::~QStyleSheetItem ()

Destroys the style. Note that QStyleSheetItem objects become owned by QStyleSheet when they are created.

int QStyleSheetItem::alignment () const

Returns the alignment of this style. Possible values are AlignAuto, AlignLeft, AlignRight, AlignCenter or AlignJustify.

See also setAlignment() and Qt::AlignmentFlags.

bool QStyleSheetItem::allowedInContext ( constQStyleSheetItem*s ) const

Returns TRUE if this style can be nested into an element of style s; otherwise returns FALSE.

See also contexts() and setContexts().

QColor QStyleSheetItem::color () const

Returns the text color of this style or an invalid color if no color has been set.

See also setColor() and QColor::isValid().

QString QStyleSheetItem::contexts () const

Returns a space-separated list of names of styles that may contain elements of this style. If nothing has been set, contexts() returns an empty string, which indicates that this style can be nested everywhere.

See also setContexts().

bool QStyleSheetItem::definesFontItalic () const

Returns TRUE if the style defines a font shape; otherwise returns FALSE. A style does not define any shape until setFontItalic() is called.

See also setFontItalic() and fontItalic().

bool QStyleSheetItem::definesFontStrikeOut () const

Returns TRUE if the style defines a setting for the strikeOut property of the font; otherwise returns FALSE. A style does not define this until setFontStrikeOut() is called.

See also setFontStrikeOut() and fontStrikeOut().

bool QStyleSheetItem::definesFontUnderline () const

Returns TRUE if the style defines a setting for the underline property of the font; otherwise returns FALSE. A style does not define this until setFontUnderline() is called.

See also setFontUnderline() and fontUnderline().

DisplayMode QStyleSheetItem::displayMode () const

Returns the display mode of the style.

See also setDisplayMode().

QString QStyleSheetItem::fontFamily () const

Returns the font family setting of the style. This is either a valid font family or QString::null if no family has been set.

See also setFontFamily(), QFont::family() and QFont::setFamily().

bool QStyleSheetItem::fontItalic () const

Returns TRUE if the style sets an italic font; otherwise returns FALSE.

See also setFontItalic() and definesFontItalic().

int QStyleSheetItem::fontSize () const

Returns the font size setting of the style. This is either a valid point size or QStyleSheetItem::Undefined.

See also setFontSize(), QFont::pointSize() and QFont::setPointSize().

bool QStyleSheetItem::fontStrikeOut () const

Returns TRUE if the style sets a strike out font; otherwise returns FALSE.

See also setFontStrikeOut() and definesFontStrikeOut().

bool QStyleSheetItem::fontUnderline () const

Returns TRUE if the style sets an underlined font; otherwise returns FALSE.

See also setFontUnderline() and definesFontUnderline().

int QStyleSheetItem::fontWeight () const

Returns the font weight setting of the style. This is either a valid QFont::Weight or the value QStyleSheetItem::Undefined.

See also setFontWeight() and QFont.

bool QStyleSheetItem::isAnchor () const

Returns whether this style is an anchor.

See also setAnchor().

int QStyleSheetItem::lineSpacing () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Returns the linespacing

ListStyle QStyleSheetItem::listStyle () const

Returns the list style of the style.

See also setListStyle() and ListStyle.

int QStyleSheetItem::logicalFontSize () const

Returns the logical font size setting of the style. This is either a valid size between 1 and 7 or QStyleSheetItem::Undefined.

See also setLogicalFontSize(), setLogicalFontSizeStep(), QFont::pointSize() and QFont::setPointSize().

int QStyleSheetItem::logicalFontSizeStep () const

Returns the logical font size step of this style.

The default is 0. Tags such as big define +1; small defines -1.

See also setLogicalFontSizeStep().

int QStyleSheetItem::margin ( Marginm ) const

Returns the width of margin m in pixels.

The margin, m, can be MarginLeft, MarginRight, MarginTop, MarginBottom, MarginAll, MarginVertical or MarginHorizontal.

See also setMargin() and Margin.

QString QStyleSheetItem::name () const

Returns the name of the style item.

int QStyleSheetItem::numberOfColumns () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Returns the number of columns for this style.

See also setNumberOfColumns(), displayMode() and setDisplayMode().

bool QStyleSheetItem::selfNesting () const

Returns TRUE if this style has self-nesting enabled; otherwise returns FALSE.

See also setSelfNesting().

void QStyleSheetItem::setAlignment ( intf )

Sets the alignment to f. This only makes sense for styles with a display mode of DisplayBlock. Possible values are AlignAuto, AlignLeft, AlignRight, AlignCenter or AlignJustify.

See also alignment(), displayMode() and Qt::AlignmentFlags.

void QStyleSheetItem::setAnchor ( boolanc )

If anc is TRUE, sets this style to be an anchor (hypertext link); otherwise sets it to not be an anchor. Elements in this style link to other documents or anchors.

See also isAnchor().

void QStyleSheetItem::setColor ( constQColor&c )

Sets the text color of this style to c.

See also color().

void QStyleSheetItem::setContexts ( constQString&c )

Sets a space-separated list of names of styles that may contain elements of this style. If c is empty, the style can be nested everywhere.

See also contexts().

void QStyleSheetItem::setDisplayMode ( DisplayModem )

Sets the display mode of the style to m.

See also displayMode().

void QStyleSheetItem::setFontFamily ( constQString&fam )

Sets the font family setting of the style to fam.

See also fontFamily(), QFont::family() and QFont::setFamily().

void QStyleSheetItem::setFontItalic ( boolitalic )

If italic is TRUE sets italic for the style; otherwise sets upright.

See also fontItalic() and definesFontItalic().

void QStyleSheetItem::setFontSize ( ints )

Sets the font size setting of the style to s points.

See also fontSize(), QFont::pointSize() and QFont::setPointSize().

void QStyleSheetItem::setFontStrikeOut ( boolstrikeOut )

If strikeOut is TRUE, sets strike out for the style; otherwise sets no strike out.

See also fontStrikeOut() and definesFontStrikeOut().

void QStyleSheetItem::setFontUnderline ( boolunderline )

If underline is TRUE, sets underline for the style; otherwise sets no underline.

See also fontUnderline() and definesFontUnderline().

void QStyleSheetItem::setFontWeight ( intw )

Sets the font weight setting of the style to w. Valid values are those defined by QFont::Weight.

See also QFont and fontWeight().

void QStyleSheetItem::setListStyle ( ListStyles )

Sets the list style of the style to s.

This is used by nested elements that have a display mode of DisplayListItem.

See also listStyle(), DisplayMode and ListStyle.

void QStyleSheetItem::setLogicalFontSize ( ints )

Sets the logical font size setting of the style to s. Valid logical sizes are 1 to 7.

See also logicalFontSize(), QFont::pointSize() and QFont::setPointSize().

void QStyleSheetItem::setLogicalFontSizeStep ( ints )

Sets the logical font size step of this style to s.

See also logicalFontSizeStep().

void QStyleSheetItem::setMargin ( Marginm, intv )

Sets the width of margin m to v pixels.

The margin, m, can be MarginLeft, MarginRight, MarginTop, MarginBottom, MarginAll, MarginVertical or MarginHorizontal. The value v must be >= 0.

See also margin().

void QStyleSheetItem::setNumberOfColumns ( intncols )

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Sets the number of columns for this style. Elements in the style are divided into columns.

This makes sense only if the style uses a block display mode (see QStyleSheetItem::DisplayMode).

See also numberOfColumns().

void QStyleSheetItem::setSelfNesting ( boolnesting )

Sets the self-nesting property for this style to nesting.

In order to support "dirty" HTML, paragraphs <p> and list items <li> are not self-nesting. This means that starting a new paragraph or list item automatically closes the previous one.

See also selfNesting().

void QStyleSheetItem::setVerticalAlignment ( VerticalAlignmentvalign )

Sets the vertical alignment to valign. Possible values are VAlignBaseline, VAlignSub or VAlignSuper.

The vertical alignment property is not inherited.

See also verticalAlignment().

void QStyleSheetItem::setWhiteSpaceMode ( WhiteSpaceModem )

Sets the whitespace mode to m.

See also WhiteSpaceMode.

QStyleSheet* QStyleSheetItem::styleSheet ()

Returns the style sheet this item is in.

constQStyleSheet* QStyleSheetItem::styleSheet () const

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns the style sheet this item is in.

VerticalAlignment QStyleSheetItem::verticalAlignment () const

Returns the vertical alignment of the style. Possible values are VAlignBaseline, VAlignSub or VAlignSuper.

See also setVerticalAlignment().

WhiteSpaceMode QStyleSheetItem::whiteSpaceMode () const

Returns the whitespace mode.

See also setWhiteSpaceMode() and WhiteSpaceMode.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文