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

QTextOption Class

The QTextOption class provides a description of general rich text properties.

All functions in this class are reentrant.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QTextOption Class▲

  • Header: QTextOption

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Gui)

    target_link_libraries(mytarget PRIVATE Qt6::Gui)

  • qmake: QT += gui

  • Group: QTextOption is part of Rich Text Processing APIs

Detailed Description▲

QTextOption is used to encapsulate common rich text properties in a single object. It contains information about text alignment, layout direction, word wrapping, and other standard properties associated with text rendering and layout.

See Also▲

Member Type Documentation▲

 

enum QTextOption::Flag▲

flags QTextOption::Flags

Constant

Value

Description

QTextOption::IncludeTrailingSpaces

0x80000000

When this option is set, QTextLine::naturalTextWidth() and naturalTextRect() will return a value that includes the width of trailing spaces in the text; otherwise this width is excluded.

QTextOption::ShowTabsAndSpaces

0x1

Visualize spaces with little dots, and tabs with little arrows. Non-breaking spaces are shown differently to breaking spaces.

QTextOption::ShowLineAndParagraphSeparators

0x2

Visualize line and paragraph separators with appropriate symbol characters.

QTextOption::ShowDocumentTerminator

0x10

Visualize the end of the document with a section sign. This enum value was added in Qt 5.7.

QTextOption::AddSpaceForLineAndParagraphSeparators

0x4

While determining the line-break positions take into account the space added for drawing a separator character.

QTextOption::SuppressColors

0x8

Suppress all color changes in the character formats (except the main selection).

The Flags type is a typedef for QFlags<Flag>. It stores an OR combination of Flag values.

enum QTextOption::TabType▲

This enum holds the different types of tabulator

Constant

Value

Description

QTextOption::LeftTab

0

A left-tab

QTextOption::RightTab

1

A right-tab

QTextOption::CenterTab

2

A centered-tab

QTextOption::DelimiterTab

3

A tab stopping at a certain delimiter-character

enum QTextOption::WrapMode▲

This enum describes how text is wrapped in a document.

Constant

Value

Description

QTextOption::NoWrap

0

Text is not wrapped at all.

QTextOption::WordWrap

1

Text is wrapped at word boundaries.

QTextOption::ManualWrap

2

Same as QTextOption::NoWrap

QTextOption::WrapAnywhere

3

Text can be wrapped at any point on a line, even if it occurs in the middle of a word.

QTextOption::WrapAtWordBoundaryOrAnywhere

4

If possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word.

Member Function Documentation▲

 

QTextOption::QTextOption()▲

Constructs a text option with default properties for text. The text alignment property is set to Qt::AlignLeft. The word wrap property is set to QTextOption::WordWrap. The using of design metrics flag is set to false.

QTextOption::QTextOption(Qt::Alignment alignment)▲

Constructs a text option with the given alignment for text. The word wrap property is set to QTextOption::WordWrap. The using of design metrics flag is set to false.

QTextOption::QTextOption(const QTextOption &other)▲

Construct a copy of the other text option.

QTextOption::~QTextOption()▲

Destroys the text option.

Qt::Alignment QTextOption::alignment() const▲

Returns the text alignment defined by the option.

See Also▲

See also setAlignment()

QTextOption::Flags QTextOption::flags() const▲

Returns the flags associated with the option.

See Also▲

See also setFlags()

void QTextOption::setAlignment(Qt::Alignment alignment)▲

Sets the option's text alignment to the specified alignment.

See Also▲

See also alignment()

void QTextOption::setFlags(QTextOption::Flags flags)▲

Sets the flags associated with the option to the given flags.

See Also▲

See also flags()

void QTextOption::setTabArray(const QList<qreal> &tabStops)▲

Sets the tab positions for the text layout to those specified by tabStops.

See Also▲

[since 5.10] void QTextOption::setTabStopDistance(qreal tabStopDistance)▲

Sets the default distance in device units between tab stops to the value specified by tabStopDistance.

This function was introduced in Qt 5.10.

See Also▲

See also tabStopDistance(), setTabArray(), setTabs(), tabs()

void QTextOption::setTabs(const QList<QTextOption::Tab> &tabStops)▲

Sets the tab positions for the text layout to those specified by tabStops.

See Also▲

See also tabs(), tabStopDistance()

void QTextOption::setTextDirection(Qt::LayoutDirection direction)▲

Sets the direction of the text layout defined by the option to the given direction.

See Also▲

See also textDirection()

void QTextOption::setUseDesignMetrics(bool enable)▲

If enable is true then the layout will use design metrics; otherwise it will use the metrics of the paint device (which is the default behavior).

See Also▲

See also useDesignMetrics()

void QTextOption::setWrapMode(QTextOption::WrapMode mode)▲

Sets the option's text wrap mode to the given mode.

See Also▲

See also wrapMode()

QList<qreal> QTextOption::tabArray() const▲

Returns a list of tab positions defined for the text layout.

See Also▲

[since 5.10] qreal QTextOption::tabStopDistance() const▲

Returns the distance in device units between tab stops.

This function was introduced in Qt 5.10.

See Also▲

See also setTabStopDistance(), tabArray(), setTabs(), tabs()

QList<QTextOption::Tab> QTextOption::tabs() const▲

Returns a list of tab positions defined for the text layout.

See Also▲

Qt::LayoutDirection QTextOption::textDirection() const▲

Returns the direction of the text layout defined by the option.

See Also▲

See also setTextDirection()

bool QTextOption::useDesignMetrics() const▲

Returns true if the layout uses design rather than device metrics; otherwise returns false.

See Also▲

See also setUseDesignMetrics()

QTextOption::WrapMode QTextOption::wrapMode() const▲

Returns the text wrap mode defined by the option.

See Also▲

See also setWrapMode()

QTextOption &QTextOption::operator=(const QTextOption &other)▲

Returns true if the text option is the same as the other text option; otherwise returns false.

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