|  | Home · All Classes · Modules

# QTextOption Class Reference
[QtGui module]

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

### Types

- enum Flag { IncludeTrailingSpaces }
- class Flags
- enum WrapMode { NoWrap, WordWrap, ManualWrap, WrapAnywhere, WrapAtWordBoundaryOrAnywhere }

### Methods

- __init__ (self)
- __init__ (self, Qt.Alignment alignment)
- __init__ (self, QTextOption o)
- Qt.Alignment alignment (self)
- Flags flags (self)
- setAlignment (self, Qt.Alignment aalignment)
- setFlags (self, Flags aflags)
- setTabArray (self, float-list tabStops)
- setTabStop (self, float atabStop)
- setTextDirection (self, Qt.LayoutDirection aDirection)
- setUseDesignMetrics (self, bool b)
- setWrapMode (self, WrapMode wrap)
- float-list tabArray (self)
- float tabStop (self)
- Qt.LayoutDirection textDirection (self)
- bool useDesignMetrics (self)
- WrapMode wrapMode (self)

## Detailed Description

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

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, and QTextCursor.

## Type Documentation

### QTextOption.Flag

Constant | Value
--- | ---
`QTextOption.IncludeTrailingSpaces` | `0x80000000`

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

### 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` | Wrapping occurs at a manually specified length from the start of the line.
`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.

## Method Documentation

### QTextOption.__init__ (self)

Constructs a text option with default properties for text.

### QTextOption.__init__ (self, Qt.Alignment alignment)

Constructs a text option with the given alignment for text.

### QTextOption.__init__ (self, QTextOption o)

Construct a copy of the other text option.

### Qt.Alignment QTextOption.alignment (self)

Returns the text alignment defined by the option.

See also setAlignment().

### Flags QTextOption.flags (self)

Returns the flags associated with the option.

See also setFlags().

### QTextOption.setAlignment (self, Qt.Alignment aalignment)

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

See also alignment().

### QTextOption.setFlags (self, Flags aflags)

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

See also flags().

### QTextOption.setTabArray (self, float-list tabStops)

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

See also tabArray() and setTabStop().

### QTextOption.setTabStop (self, float atabStop)

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

See also tabStop() and setTabArray().

### QTextOption.setTextDirection (self, Qt.LayoutDirection aDirection)

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

See also textDirection().

### QTextOption.setUseDesignMetrics (self, bool b)

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

### QTextOption.setWrapMode (self, WrapMode wrap)

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

See also wrapMode().

### float-list QTextOption.tabArray (self)

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

See also setTabArray() and tabStop().

### float QTextOption.tabStop (self)

Returns the distance in device units between tab stops.

See also setTabStop() and tabArray().

### Qt.LayoutDirection QTextOption.textDirection (self)

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

See also setTextDirection().

### bool QTextOption.useDesignMetrics (self)

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

See also setUseDesignMetrics().

### WrapMode QTextOption.wrapMode (self)

Returns the text wrap mode defined by the option.

See also setWrapMode().