IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QTextListFormat Class

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

All functions in this class are reentrant.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QTextListFormat Class

  • Header: QTextListFormat

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Gui)

    target_link_libraries(mytarget PRIVATE Qt6::Gui)

  • qmake: QT += gui

  • Inherits: QTextFormat

  • Group: QTextListFormat is part of Rich Text Processing APIs, shared

Detailed Description

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

 
Sélectionnez
QTextListFormat listFormat;

listFormat.setStyle(QTextListFormat::ListDecimal);
listFormat.setNumberPrefix("(");
listFormat.setNumberSuffix(")");

cursor.insertList(listFormat);

See Also

See also QTextList

Member Type Documentation

 

enum QTextListFormat::Style

This enum describes the symbols used to decorate list items:

Constant

Value

Description

QTextListFormat::ListDisc

-1

a filled circle

QTextListFormat::ListCircle

-2

an empty circle

QTextListFormat::ListSquare

-3

a filled square

QTextListFormat::ListDecimal

-4

decimal values in ascending order

QTextListFormat::ListLowerAlpha

-5

lower case Latin characters in alphabetical order

QTextListFormat::ListUpperAlpha

-6

upper case Latin characters in alphabetical order

QTextListFormat::ListLowerRoman

-7

lower case roman numerals (supports up to 4999 items only)

QTextListFormat::ListUpperRoman

-8

upper case roman numerals (supports up to 4999 items only)

Member Function Documentation

 

QTextListFormat::QTextListFormat()

Constructs a new list format object.

int QTextListFormat::indent() const

Returns the list format's indentation. The indentation is multiplied by the QTextDocument::indentWidth property to get the effective indent in pixels.

See Also

See also setIndent()

bool QTextListFormat::isValid() const

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

QString QTextListFormat::numberPrefix() const

Returns the list format's number prefix.

See Also

See also setNumberPrefix()

QString QTextListFormat::numberSuffix() const

Returns the list format's number suffix.

See Also

See also setNumberSuffix()

void QTextListFormat::setIndent(int indentation)

Sets the list format's indentation. The indentation is multiplied by the QTextDocument::indentWidth property to get the effective indent in pixels.

See Also

See also indent()

void QTextListFormat::setNumberPrefix(const QString &numberPrefix)

Sets the list format's number prefix to the string specified by numberPrefix. 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

See also numberPrefix()

void QTextListFormat::setNumberSuffix(const QString &numberSuffix)

Sets the list format's number suffix to the string specified by numberSuffix. 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

See also numberSuffix()

void QTextListFormat::setStyle(QTextListFormat::Style style)

Sets the list format's style.

See Also

See also style(), Style

QTextListFormat::Style QTextListFormat::style() const

Returns the list format's style.

See Also

See also setStyle(), Style

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+