| Classes - Annotated - Tree - Functions - Home - Structure

# QStyleSheetItem Class Reference

The QStyleSheetItem class encapsulates a text format. More...

`#include <qstylesheet.h>`

Inherits Qt.

List of all member functions.

## Public Members

- QStyleSheetItem ( QStyleSheet * parent, const QString & name )
- QStyleSheetItem ( const QStyleSheetItem & )
- ~QStyleSheetItem ()
- QString name () const
- QStyleSheet* styleSheet ()
- const QStyleSheet* styleSheet () const
- enum AdditionalStyleValues { Undefined = - 1}
- enum DisplayMode { DisplayBlock, DisplayInline, DisplayListItem, DisplayNone }
- DisplayMode displayMode () const
- void setDisplayMode ( DisplayMode m )
- int alignment () const
- void setAlignment ( int f )
- int fontWeight () const
- void setFontWeight ( int w )
- int logicalFontSize () const
- void setLogicalFontSize ( int s )
- int logicalFontSizeStep () const
- void setLogicalFontSizeStep ( int s )
- int fontSize () const
- void setFontSize ( int s )
- QString fontFamily () const
- void setFontFamily ( const QString & )
- int numberOfColumns () const (obsolete)
- void setNumberOfColumns ( int ncols ) (obsolete)
- QColor color () const
- void setColor ( const QColor & )
- bool fontItalic () const
- void setFontItalic ( bool )
- bool definesFontItalic () const
- bool fontUnderline () const
- void setFontUnderline ( bool )
- bool definesFontUnderline () const
- bool isAnchor () const
- void setAnchor ( bool anc )
- enum WhiteSpaceMode { WhiteSpaceNormal, WhiteSpacePre, WhiteSpaceNoWrap }
- WhiteSpaceMode whiteSpaceMode () const
- void setWhiteSpaceMode ( WhiteSpaceMode m )
- enum Margin { MarginLeft, MarginRight, MarginTop, MarginBottom, MarginAll, MarginVertical, MarginHorizontal }
- int margin ( Margin m ) const
- void setMargin ( Margin, int )
- enum ListStyle { ListDisc, ListCircle, ListSquare, ListDecimal, ListLowerAlpha, ListUpperAlpha }
- ListStyle listStyle () const
- void setListStyle ( ListStyle )
- QString contexts () const
- void setContexts ( const QString & )
- bool allowedInContext ( const QStyleSheetItem * ) const
- bool selfNesting () const
- void setSelfNesting ( bool )

## Detailed Description

The QStyleSheetItem class encapsulates a text format.

A style consists of a name and a set of font, color, and other display properties. When used in a style sheet, items define the name of a rich text tag, and the display property changes associated with it.

## Member Type Documentation

### QStyleSheetItem::DisplayMode

This enum type defines the way adjacent elements are displayed. The possible values are:

- `DisplayBlock` - elements are displayed as a rectangular block. (eg. <P> ... </P>)
- `DisplayInline` - elements are displayed in a horizontally flowing sequence. (eg. <EM> ... </EM>)
- `DisplayListItem` - elements are displayed in a vertically sequence. (eg. <EM> ... </EM>)
- `DisplayNone` - elements are not displayed at all.

### QStyleSheetItem::ListStyle

This enum type defines how the items in a list are prefixed when displayed. The currently defined values are:

- `ListDisc` - a filled circle
- `ListCircle` - an unfilled circle
- `ListSquare` - a filled circle
- `ListDecimal` - an integer in base 10: 1, 2, 3, ...
- `ListLowerAlpha` - a lowercase letter: a, b, c, ...
- `ListUpperAlpha` - an uppercase letter: A, B, C, ...

### QStyleSheetItem::Margin

- `MarginLeft` - left margin
- `MarginRight` - right margin
- `MarginTop` - top margin
- `MarginBottom` - bottom margin
- `MarginAll` - all margins (left, right, top and bottom )
- `MarginVertical` - top and bottom margin
- `MarginHorizontal` - left and right margin

### QStyleSheetItem::WhiteSpaceMode

This enum defines the ways in which QStyleSheet can treat white space. There are three values at present:

- `WhiteSpaceNormal` - any sequence of white space is equivalent to a single space, and is a line-break position.
- `WhiteSpacePre` - white space must be output exactly as given in the input.
- `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, const QString & name )

Constructs a new style named 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 ( const QStyleSheetItem & other )

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

### QStyleSheetItem::~QStyleSheetItem ()

Destructs 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 AlignLeft, AlignRight and AlignCenter.

See also setAlignment() and Qt::AlignmentFlags.

### bool QStyleSheetItem::allowedInContext ( const QStyleSheetItem * s ) const

Returns whether this style can be nested into an element of style s .

See also contxts() and setContexts().

### QColor QStyleSheetItem::color () const

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

See also setColor().

### QString QStyleSheetItem::contexts () const

Returns a space separated list of names of styles that may contain elements of this style. As default, contexs() returns an empty string, which indicates that this style can be nested everywhere.

See also setContexts().

### bool QStyleSheetItem::definesFontItalic () const

Returns whether the style defines a font shape. A style does not define any shape until setFontItalic() is called.

See also setFontItalic() and fontItalic().

### bool QStyleSheetItem::definesFontUnderline () const

Returns whether the style defines a setting for the underline property of the font. A style does not define this until setFontUnderline() is called.

See also setFontUnderline() and fontUnderline().

### QStyleSheetItem::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 whether the styles sets an italic or upright font.

See also setFontItalic() and definesFontItalic().

### int QStyleSheetItem::fontSize () const

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

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

### bool QStyleSheetItem::fontUnderline () const

Returns whether the styles sets an underlined font.

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().

### QStyleSheetItem::ListStyle QStyleSheetItem::listStyle() const

Returns the list style of the style.

See also setListStyle().

### 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 like `big` define `+1, small` defines `-1`

See also setLogicalFontSizeStep().

### int QStyleSheetItem::margin ( Margin m ) const

Returns the width of margin m in pixel.

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

See also setMargin().

### QString QStyleSheetItem::name () const

Returns the name of style.

### int QStyleSheetItem::numberOfColumns () const

This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. 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 whether this style has self nesting enabled.

See also setSelfNesting().

### void QStyleSheetItem::setAlignment ( int f )

Sets the alignment. This only makes sense for styles with display mode DisplayBlock. Possible values are AlignLeft, AlignRight and AlignCenter.

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

### void QStyleSheetItem::setAnchor ( bool anc )

Sets whether the style is an anchor (link). Elements in this style have connections to other documents or anchors.

See also isAnchor().

### void QStyleSheetItem::setColor ( const QColor & c )

Sets the text color of this style.

See also color().

### void QStyleSheetItem::setContexts ( const QString & 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 ( DisplayMode m )

Sets the display mode of the style to m.

See also displayMode().

### void QStyleSheetItem::setFontFamily ( const QString & fam )

Sets the font family setting of the style.

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

### void QStyleSheetItem::setFontItalic ( bool italic )

Sets italic or upright shape for the style.

See also fontItalic() and definesFontItalic().

### void QStyleSheetItem::setFontSize ( int s )

Sets the font size setting of the style, in point measures.

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

### void QStyleSheetItem::setFontUnderline ( bool underline )

Sets underline for the style.

See also fontUnderline() and definesFontUnderline().

### void QStyleSheetItem::setFontWeight ( int w )

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

See also QFont and fontWeight().

### void QStyleSheetItem::setListStyle ( ListStyle s )

Sets the list style of the style.

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

See also listStyle() and DisplayMode.

### void QStyleSheetItem::setLogicalFontSize ( int s )

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

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

### void QStyleSheetItem::setLogicalFontSizeStep ( int s )

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

See also logicalFontSizeStep().

### void QStyleSheetItem::setMargin ( Margin m, int v )

Sets the width of margin m to v pixels.

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

See also margin().

### void QStyleSheetItem::setNumberOfColumns ( int ncols )

This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. 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 only makes sense if the style uses a block display mode.

See also numberOfColumns().

### void QStyleSheetItem::setSelfNesting ( bool nesting )

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::setWhiteSpaceMode ( WhiteSpaceMode m )

Sets the white space mode to m. Possible values are

- `WhiteSpaceNormal` - white spaces in the document only serve as separators. Multiple spaces or indentation therefore is ignored.
- `WhiteSpacePre` - white spaces are preserved. This is particularly useful to display programming code.
- `WhiteSpaceNoWrap` - multiple spaces are collapsed as with WhiteSpaceNormal, but no automatic line breaks occur. To break lines manually, use the `<br>` tag.

### QStyleSheet* QStyleSheetItem::styleSheet ()

Returns the stylesheet this item is in.

### const QStyleSheet* QStyleSheetItem::styleSheet () const

Returns the stylesheet this item is in.

### QStyleSheetItem::WhiteSpaceMode QStyleSheetItem::whiteSpaceMode() const

Returns the white space mode.

See also setWhiteSpaceMode().

Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):

This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.