Qt logo

QStyleSheet Class Reference


A collection of styles for rich text rendering and a generator of tags. More...

#include <qstylesheet.h>

Inherits QObject.

List of all member functions.

Public Members

Static Public Members


Detailed Description

A collection of styles for rich text rendering and a generator of tags.

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

The default QStyleSheet object has the following style bindings:


Member Function Documentation

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

By default, the style sheet has the tag definitions defined above.

QStyleSheet::~QStyleSheet () [virtual]

Destroys the style sheet. All styles inserted into the style sheet will be deleted.

QString QStyleSheet::convertFromPlainText ( const QString & plain ) [static]

Auxiliary function. Converts the plain text string plain to a rich text formatted string while preserving its look.

QStyleSheet* QStyleSheet::defaultSheet () [static]

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.

See also: setDefaultSheet().

Examples: qbrowser/main.cpp

void QStyleSheet::error ( const QString & msg ) const [virtual]

This virtual function is called when an error occurs when processsing rich text. Reimplement if if you need to catch error messages.

Errors 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.

msg is the error message.

void QStyleSheet::insert ( QStyleSheetItem * style )

For internal use only.

QStyleSheetItemQStyleSheet::item ( const QString & name )

Returns the style with name name or 0 if there is no such style.

const QStyleSheetItemQStyleSheet::item ( const QString & name ) const

Returns the style with name name or 0 if there is no such style (const version).

bool QStyleSheet::mightBeRichText ( const QString & text ) [static]

Returns whether the string text is likely to be rich text formatted.

Note: 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.

void QStyleSheet::scaleFont ( QFont & font, int logicalSize ) const [virtual]

Scales the font font to the appropriate physical point size corresponding to the logical font size logicalSize.

When calling this function, font has a point size corresponding to the logical font size 3.

Typical logical font sizes range from 1 to 7, with 1 being the smallest.

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

void QStyleSheet::setDefaultSheet ( QStyleSheet * sheet ) [static]

Sets the application-wide default style sheet, deleting any style sheet previously set. The ownership is transferred.

See also: defaultSheet().

QTextNode* QStyleSheet::tag ( const QString & name, const QMap<QString, QString> & attr, const QString & context, const QMimeSourceFactory & factory, bool emptyTag = FALSE ) const [virtual]

Generates an internal object for tag named name, given the attributes attr, and using additional information provided by the mime source factory factory .

This function should not (yet) be used in application code.


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


This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.


Copyright İ 1999 Troll TechTrademarks
Qt version 2.0.2