QTextOption

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

Inheritance diagram of PySide2.QtGui.QTextOption

Synopsis

Functions

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

QTextEdit QTextDocument QTextCursor

class PySide2.QtGui.QTextOption

PySide2.QtGui.QTextOption(alignment)

PySide2.QtGui.QTextOption(o)

param o:

PySide2.QtGui.QTextOption

param alignment:

Alignment

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

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

PySide2.QtGui.QTextOption.TabType

This enum holds the different types of tabulator

Constant

Description

QTextOption.LeftTab

A left-tab

QTextOption.RightTab

A right-tab

QTextOption.CenterTab

A centered-tab

QTextOption.DelimiterTab

A tab stopping at a certain delimiter-character

PySide2.QtGui.QTextOption.WrapMode

This enum describes how text is wrapped in a document.

Constant

Description

QTextOption.NoWrap

Text is not wrapped at all.

QTextOption.WordWrap

Text is wrapped at word boundaries.

QTextOption.ManualWrap

Same as

QTextOption.WrapAnywhere

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

QTextOption.WrapAtWordBoundaryOrAnywhere

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.

PySide2.QtGui.QTextOption.Flag

Constant

Description

QTextOption.IncludeTrailingSpaces

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

QTextOption.ShowTabsAndSpaces

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

QTextOption.ShowLineAndParagraphSeparators

Visualize line and paragraph separators with appropriate symbol characters.

QTextOption.ShowDocumentTerminator

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

QTextOption.AddSpaceForLineAndParagraphSeparators

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

QTextOption.SuppressColors

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

PySide2.QtGui.QTextOption.alignment()
Return type:

Alignment

Returns the text alignment defined by the option.

See also

setAlignment()

PySide2.QtGui.QTextOption.flags()
Return type:

Flags

Returns the flags associated with the option.

See also

setFlags()

PySide2.QtGui.QTextOption.setAlignment(alignment)
Parameters:

alignmentAlignment

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

See also

alignment()

PySide2.QtGui.QTextOption.setFlags(flags)
Parameters:

flagsFlags

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

See also

flags()

PySide2.QtGui.QTextOption.setTabArray(tabStops)
Parameters:

tabStops

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

PySide2.QtGui.QTextOption.setTabStop(tabStop)
Parameters:

tabStop – float

Note

This function is deprecated.

in Qt 5.10. Use setTabStopDistance() instead.

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

PySide2.QtGui.QTextOption.setTabStopDistance(tabStopDistance)
Parameters:

tabStopDistance – float

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

PySide2.QtGui.QTextOption.setTabs(tabStops)
Parameters:

tabStops

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

See also

tabs() tabStop()

PySide2.QtGui.QTextOption.setTextDirection(aDirection)
Parameters:

aDirectionLayoutDirection

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

See also

textDirection()

PySide2.QtGui.QTextOption.setUseDesignMetrics(b)
Parameters:

b – bool

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

PySide2.QtGui.QTextOption.setWrapMode(wrap)
Parameters:

wrapWrapMode

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

See also

wrapMode()

PySide2.QtGui.QTextOption.tabArray()
Return type:

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

PySide2.QtGui.QTextOption.tabStop()
Return type:

float

Note

This function is deprecated.

in Qt 5.10. Use tabStopDistance() instead.

Returns the distance in device units between tab stops. Convenient function for the above method

PySide2.QtGui.QTextOption.tabStopDistance()
Return type:

float

Returns the distance in device units between tab stops.

PySide2.QtGui.QTextOption.tabs()
Return type:

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

PySide2.QtGui.QTextOption.textDirection()
Return type:

LayoutDirection

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

PySide2.QtGui.QTextOption.useDesignMetrics()
Return type:

bool

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

PySide2.QtGui.QTextOption.wrapMode()
Return type:

WrapMode

Returns the text wrap mode defined by the option.

See also

setWrapMode()