Qt 4.8
Public Types | Public Functions | Protected Functions | Friends | List of all members
QTextListFormat Class Reference

The QTextListFormat class provides formatting information for lists in a QTextDocument. More...

#include <qtextformat.h>

Inheritance diagram for QTextListFormat:
QTextFormat

Public Types

enum  Style {
  ListDisc = -1, ListCircle = -2, ListSquare = -3, ListDecimal = -4,
  ListLowerAlpha = -5, ListUpperAlpha = -6, ListLowerRoman = -7, ListUpperRoman = -8,
  ListStyleUndefined = 0
}
 This enum describes the symbols used to decorate list items: More...
 
- Public Types inherited from QTextFormat
enum  FormatType {
  InvalidFormat = -1, BlockFormat = 1, CharFormat = 2, ListFormat = 3,
  TableFormat = 4, FrameFormat = 5, UserFormat = 100
}
 This enum describes the text item a QTextFormat object is formatting. More...
 
enum  ObjectTypes {
  NoObject, ImageObject, TableObject, TableCellObject,
  UserObject = 0x1000
}
 This enum describes what kind of QTextObject this format is associated with. More...
 
enum  PageBreakFlag { PageBreak_Auto = 0, PageBreak_AlwaysBefore = 0x001, PageBreak_AlwaysAfter = 0x010 }
 This enum describes how page breaking is performed when printing. More...
 
enum  Property {
  ObjectIndex = 0x0, CssFloat = 0x0800, LayoutDirection = 0x0801, OutlinePen = 0x810,
  BackgroundBrush = 0x820, ForegroundBrush = 0x821, BackgroundImageUrl = 0x823, BlockAlignment = 0x1010,
  BlockTopMargin = 0x1030, BlockBottomMargin = 0x1031, BlockLeftMargin = 0x1032, BlockRightMargin = 0x1033,
  TextIndent = 0x1034, TabPositions = 0x1035, BlockIndent = 0x1040, LineHeight = 0x1048,
  LineHeightType = 0x1049, BlockNonBreakableLines = 0x1050, BlockTrailingHorizontalRulerWidth = 0x1060, FirstFontProperty = 0x1FE0,
  FontCapitalization = FirstFontProperty, FontLetterSpacing = 0x1FE1, FontWordSpacing = 0x1FE2, FontStyleHint = 0x1FE3,
  FontStyleStrategy = 0x1FE4, FontKerning = 0x1FE5, FontHintingPreference = 0x1FE6, FontFamily = 0x2000,
  FontPointSize = 0x2001, FontSizeAdjustment = 0x2002, FontSizeIncrement = FontSizeAdjustment, FontWeight = 0x2003,
  FontItalic = 0x2004, FontUnderline = 0x2005, FontOverline = 0x2006, FontStrikeOut = 0x2007,
  FontFixedPitch = 0x2008, FontPixelSize = 0x2009, LastFontProperty = FontPixelSize, TextUnderlineColor = 0x2010,
  TextVerticalAlignment = 0x2021, TextOutline = 0x2022, TextUnderlineStyle = 0x2023, TextToolTip = 0x2024,
  IsAnchor = 0x2030, AnchorHref = 0x2031, AnchorName = 0x2032, ObjectType = 0x2f00,
  ListStyle = 0x3000, ListIndent = 0x3001, ListNumberPrefix = 0x3002, ListNumberSuffix = 0x3003,
  FrameBorder = 0x4000, FrameMargin = 0x4001, FramePadding = 0x4002, FrameWidth = 0x4003,
  FrameHeight = 0x4004, FrameTopMargin = 0x4005, FrameBottomMargin = 0x4006, FrameLeftMargin = 0x4007,
  FrameRightMargin = 0x4008, FrameBorderBrush = 0x4009, FrameBorderStyle = 0x4010, TableColumns = 0x4100,
  TableColumnWidthConstraints = 0x4101, TableCellSpacing = 0x4102, TableCellPadding = 0x4103, TableHeaderRowCount = 0x4104,
  TableCellRowSpan = 0x4810, TableCellColumnSpan = 0x4811, TableCellTopPadding = 0x4812, TableCellBottomPadding = 0x4813,
  TableCellLeftPadding = 0x4814, TableCellRightPadding = 0x4815, ImageName = 0x5000, ImageWidth = 0x5010,
  ImageHeight = 0x5011, FullWidthSelection = 0x06000, PageBreakPolicy = 0x7000, UserProperty = 0x100000
}
 This enum describes the different properties a format can have. More...
 

Public Functions

int indent () const
 Returns the list format's indentation. More...
 
bool isValid () const
 Returns true if this list format is valid; otherwise returns false. More...
 
QString numberPrefix () const
 Returns the list format's number prefix. More...
 
QString numberSuffix () const
 Returns the list format's number suffix. More...
 
 QTextListFormat ()
 Constructs a new list format object. More...
 
void setIndent (int indent)
 Sets the list format's indentation. More...
 
void setNumberPrefix (const QString &numberPrefix)
 Sets the list format's number prefix to the string specified by numberPrefix. More...
 
void setNumberSuffix (const QString &numberSuffix)
 Sets the list format's number suffix to the string specified by numberSuffix. More...
 
void setStyle (Style style)
 Sets the list format's style. More...
 
Style style () const
 Returns the list format's style. More...
 
- Public Functions inherited from QTextFormat
QBrush background () const
 Returns the brush used to paint the document's background. More...
 
bool boolProperty (int propertyId) const
 Returns the value of the property specified by propertyId. More...
 
QBrush brushProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QVariant::Brush type, Qt::NoBrush is returned instead. More...
 
void clearBackground ()
 Clears the brush used to paint the document's background. More...
 
void clearForeground ()
 Clears the brush used to paint the document's foreground. More...
 
void clearProperty (int propertyId)
 Clears the value of the property given by propertyId. More...
 
QColor colorProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QVariant::Color type, an invalid color is returned instead. More...
 
qreal doubleProperty (int propertyId) const
 Returns the value of the property specified by propertyId. More...
 
QBrush foreground () const
 Returns the brush used to render foreground details, such as text, frame outlines, and table borders. More...
 
bool hasProperty (int propertyId) const
 Returns true if the text format has a property with the given propertyId; otherwise returns false. More...
 
int intProperty (int propertyId) const
 Returns the value of the property specified by propertyId. More...
 
bool isBlockFormat () const
 Returns true if this text format is a BlockFormat; otherwise returns false. More...
 
bool isCharFormat () const
 Returns true if this text format is a CharFormat; otherwise returns false. More...
 
bool isFrameFormat () const
 Returns true if this text format is a FrameFormat; otherwise returns false. More...
 
bool isImageFormat () const
 Returns true if this text format is an image format; otherwise returns false. More...
 
bool isListFormat () const
 Returns true if this text format is a ListFormat; otherwise returns false. More...
 
bool isTableCellFormat () const
 Returns true if this text format is a TableCellFormat; otherwise returns false. More...
 
bool isTableFormat () const
 Returns true if this text format is a TableFormat; otherwise returns false. More...
 
bool isValid () const
 Returns true if the format is valid (i. More...
 
Qt::LayoutDirection layoutDirection () const
 Returns the document's layout direction. More...
 
QTextLength lengthProperty (int propertyId) const
 Returns the value of the property given by propertyId. More...
 
QVector< QTextLengthlengthVectorProperty (int propertyId) const
 Returns the value of the property given by propertyId. More...
 
void merge (const QTextFormat &other)
 Merges the other format with this format; where there are conflicts the other format takes precedence. More...
 
int objectIndex () const
 Returns the index of the format object, or -1 if the format object is invalid. More...
 
int objectType () const
 Returns the text format's object type. More...
 
 operator QVariant () const
 Returns the text format as a QVariant. More...
 
bool operator!= (const QTextFormat &rhs) const
 Returns true if this text format is different from the other text format. More...
 
QTextFormatoperator= (const QTextFormat &rhs)
 Assigns the other text format to this text format, and returns a reference to this text format. More...
 
bool operator== (const QTextFormat &rhs) const
 Returns true if this text format is the same as the other text format. More...
 
QPen penProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QVariant::Pen type, Qt::NoPen is returned instead. More...
 
QMap< int, QVariantproperties () const
 Returns a map with all properties of this text format. More...
 
QVariant property (int propertyId) const
 Returns the property specified by the given propertyId. More...
 
int propertyCount () const
 Returns the number of properties stored in the format. More...
 
 QTextFormat ()
 Creates a new text format with an InvalidFormat. More...
 
 QTextFormat (int type)
 Creates a new text format of the given type. More...
 
 QTextFormat (const QTextFormat &rhs)
 Creates a new text format with the same attributes as the other text format. More...
 
void setBackground (const QBrush &brush)
 Sets the brush use to paint the document's background to the brush specified. More...
 
void setForeground (const QBrush &brush)
 Sets the foreground brush to the specified brush. More...
 
void setLayoutDirection (Qt::LayoutDirection direction)
 Sets the document's layout direction to the specified direction. More...
 
void setObjectIndex (int object)
 Sets the format object's object index. More...
 
void setObjectType (int type)
 Sets the text format's object type to type. More...
 
void setProperty (int propertyId, const QVariant &value)
 Sets the property specified by the propertyId to the given value. More...
 
void setProperty (int propertyId, const QVector< QTextLength > &lengths)
 Sets the value of the property given by propertyId to value. More...
 
QString stringProperty (int propertyId) const
 Returns the value of the property given by propertyId; if the property isn't of QVariant::String type, an empty string is returned instead. More...
 
QTextBlockFormat toBlockFormat () const
 Returns this format as a block format. More...
 
QTextCharFormat toCharFormat () const
 Returns this format as a character format. More...
 
QTextFrameFormat toFrameFormat () const
 Returns this format as a frame format. More...
 
QTextImageFormat toImageFormat () const
 Returns this format as an image format. More...
 
QTextListFormat toListFormat () const
 Returns this format as a list format. More...
 
QTextTableCellFormat toTableCellFormat () const
 Returns this format as a table cell format. More...
 
QTextTableFormat toTableFormat () const
 Returns this format as a table format. More...
 
int type () const
 Returns the type of this format. More...
 
 ~QTextFormat ()
 Destroys this text format. More...
 

Protected Functions

 QTextListFormat (const QTextFormat &fmt)
 Creates a new list format with the same attributes as the given text format. More...
 

Friends

class QTextFormat
 

Detailed Description

The QTextListFormat class provides formatting information for lists in a QTextDocument.

Note
This class or function is reentrant.

A list is composed of one or more items, represented as text blocks. The list's format specifies the appearance of items in the list. In particular, it determines the indentation and the style of each item.

The indentation of the items is an integer value that causes each item to be offset from the left margin by a certain amount. This value is read with indent() and set with setIndent().

The style used to decorate each item is set with setStyle() and can be read with the style() function. The style controls the type of bullet points and numbering scheme used for items in the list. Note that lists that use the decimal numbering scheme begin counting at 1 rather than 0.

Style properties can be set to further configure the appearance of list items; for example, the ListNumberPrefix and ListNumberSuffix properties can be used to customize the numbers used in an ordered list so that they appear as (1), (2), (3), etc.:

QTextListFormat listFormat;
listFormat.setNumberPrefix("(");
listFormat.setNumberSuffix(")");
cursor.insertList(listFormat);
See also
QTextList

Definition at line 642 of file qtextformat.h.

Enumerations

◆ Style

This enum describes the symbols used to decorate list items:

  • ListDisc a filled circle
  • ListCircle an empty circle
  • ListSquare a filled square
  • ListDecimal decimal values in ascending order
  • ListLowerAlpha lower case Latin characters in alphabetical order
  • ListUpperAlpha upper case Latin characters in alphabetical order
  • ListLowerRoman lower case roman numerals (supports up to 4999 items only)
  • ListUpperRoman upper case roman numerals (supports up to 4999 items only)
  • ListStyleUndefined
Enumerator
ListDisc 
ListCircle 
ListSquare 
ListDecimal 
ListLowerAlpha 
ListUpperAlpha 
ListLowerRoman 
ListUpperRoman 
ListStyleUndefined 

Definition at line 649 of file qtextformat.h.

Constructors and Destructors

◆ QTextListFormat() [1/2]

QTextListFormat::QTextListFormat ( )

Constructs a new list format object.

Definition at line 2643 of file qtextformat.cpp.

2645 {
2646  setIndent(1);
2647 }
QTextFormat()
Creates a new text format with an InvalidFormat.
void setIndent(int indent)
Sets the list format&#39;s indentation.
Definition: qtextformat.h:685

◆ QTextListFormat() [2/2]

QTextListFormat::QTextListFormat ( const QTextFormat other)
explicitprotected

Creates a new list format with the same attributes as the given text format.

Warning
This function is not part of the public interface.

Definition at line 2659 of file qtextformat.cpp.

2660  : QTextFormat(fmt)
2661 {
2662 }
QTextFormat()
Creates a new text format with an InvalidFormat.

Functions

◆ indent()

int QTextListFormat::indent ( ) const
inline

Returns the list format's indentation.

The indentation is multiplied by the QTextDocument::indentWidth property to get the effective indent in pixels.

See also
setIndent()

Definition at line 666 of file qtextformat.h.

Referenced by QTextDocumentLayoutPrivate::blockIndent(), QTextHtmlExporter::emitBlock(), QTextControlPrivate::indent(), QTextControlPrivate::outdent(), QTextList::remove(), QTextOdfWriter::writeBlock(), and QTextOdfWriter::writeListFormat().

667  { return intProperty(ListIndent); }
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ isValid()

bool QTextListFormat::isValid ( ) const
inline

Returns true if this list format is valid; otherwise returns false.

Definition at line 647 of file qtextformat.h.

647 { return isListFormat(); }
bool isListFormat() const
Returns true if this text format is a ListFormat; otherwise returns false.
Definition: qtextformat.h:320

◆ numberPrefix()

int QTextListFormat::numberPrefix ( ) const
inline

Returns the list format's number prefix.

Since
4.8
See also
setNumberPrefix()

Definition at line 670 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitBlock(), QTextList::itemText(), and QTextOdfWriter::writeListFormat().

671  { return stringProperty(ListNumberPrefix); }
QString stringProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn&#39;t of QVariant::String type...

◆ numberSuffix()

int QTextListFormat::numberSuffix ( ) const
inline

Returns the list format's number suffix.

Since
4.8
See also
setNumberSuffix()

Definition at line 674 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitBlock(), QTextList::itemText(), and QTextOdfWriter::writeListFormat().

675  { return stringProperty(ListNumberSuffix); }
QString stringProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn&#39;t of QVariant::String type...

◆ setIndent()

void QTextListFormat::setIndent ( int  indentation)
inline

Sets the list format's indentation.

The indentation is multiplied by the QTextDocument::indentWidth property to get the effective indent in pixels.

See also
indent()

Definition at line 685 of file qtextformat.h.

Referenced by QTextControlPrivate::createAutoBulletList(), QTextEditPrivate::createAutoBulletList(), QTextControlPrivate::indent(), QTextControlPrivate::outdent(), QTextHtmlImporter::processSpecialNodes(), and QTextListFormat().

686 { setProperty(ListIndent, aindent); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setNumberPrefix()

void QTextListFormat::setNumberPrefix ( const QString numberPrefix)
inline

Sets the list format's number prefix to the string specified by numberPrefix.

Since
4.8

This can be used with all sorted list types. It does not have any effect on unsorted list types.

The default prefix is an empty string.

See also
numberPrefix()

Definition at line 688 of file qtextformat.h.

Referenced by QTextHtmlImporter::processSpecialNodes().

void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setNumberSuffix()

void QTextListFormat::setNumberSuffix ( const QString numberSuffix)
inline

Sets the list format's number suffix to the string specified by numberSuffix.

Since
4.8

This can be used with all sorted list types. It does not have any effect on unsorted list types.

The default suffix is ".".

See also
numberSuffix()

Definition at line 691 of file qtextformat.h.

Referenced by QTextHtmlImporter::processSpecialNodes().

void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setStyle()

void QTextListFormat::setStyle ( Style  style)
inline

Sets the list format's style.

See also
style() Style

Definition at line 682 of file qtextformat.h.

Referenced by QTextControlPrivate::createAutoBulletList(), QTextEditPrivate::createAutoBulletList(), QTextCursor::createList(), and QTextHtmlImporter::processSpecialNodes().

683 { setProperty(ListStyle, astyle); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ style()

Style QTextListFormat::style ( ) const
inline

Returns the list format's style.

See also
setStyle() Style

Definition at line 662 of file qtextformat.h.

Referenced by QTextDocumentLayoutPrivate::drawBlock(), QTextDocumentLayoutPrivate::drawListItem(), QTextHtmlExporter::emitBlock(), QTextList::itemText(), and QTextOdfWriter::writeListFormat().

663  { return static_cast<Style>(intProperty(ListStyle)); }
Style
This enum describes the symbols used to decorate list items:
Definition: qtextformat.h:649
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

Friends and Related Functions

◆ QTextFormat

friend class QTextFormat
friend

Definition at line 679 of file qtextformat.h.


The documentation for this class was generated from the following files: