CopperSpice API
1.9.2
|
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument. More...
Public Types | |
enum | LineHeightTypes |
Public Types inherited from QTextFormat | |
enum | FormatType |
enum | ObjectTypes |
enum | Property |
Public Methods | |
QTextBlockFormat () | |
Qt::Alignment | alignment () const |
qreal | bottomMargin () const |
int | indent () const |
bool | isValid () const |
qreal | leftMargin () const |
qreal | lineHeight () const |
qreal | lineHeight (qreal scriptLineHeight, qreal scaling) const |
int | lineHeightType () const |
bool | nonBreakableLines () const |
PageBreakFlags | pageBreakPolicy () const |
qreal | rightMargin () const |
void | setAlignment (Qt::Alignment alignment) |
void | setBottomMargin (qreal margin) |
void | setIndent (int indent) |
void | setLeftMargin (qreal margin) |
void | setLineHeight (qreal height, int heightType) |
void | setNonBreakableLines (bool b) |
void | setPageBreakPolicy (PageBreakFlags policy) |
void | setRightMargin (qreal margin) |
void | setTabPositions (const QList< QTextOption::Tab > &tabs) |
void | setTextIndent (qreal indent) |
void | setTopMargin (qreal margin) |
QList< QTextOption::Tab > | tabPositions () const |
qreal | textIndent () const |
qreal | topMargin () const |
Public Methods inherited from QTextFormat | |
QTextFormat () | |
QTextFormat (const QTextFormat &other) | |
QTextFormat (int type) | |
~QTextFormat () | |
QBrush | background () const |
bool | boolProperty (int propertyId) const |
QBrush | brushProperty (int propertyId) const |
void | clearBackground () |
void | clearForeground () |
void | clearProperty (int propertyId) |
QColor | colorProperty (int propertyId) const |
qreal | doubleProperty (int propertyId) const |
QBrush | foreground () const |
bool | hasProperty (int propertyId) const |
int | intProperty (int propertyId) const |
bool | isBlockFormat () const |
bool | isCharFormat () const |
bool | isEmpty () const |
bool | isFrameFormat () const |
bool | isImageFormat () const |
bool | isListFormat () const |
bool | isTableCellFormat () const |
bool | isTableFormat () const |
bool | isValid () const |
Qt::LayoutDirection | layoutDirection () const |
QTextLength | lengthProperty (int propertyId) const |
QVector< QTextLength > | lengthVectorProperty (int propertyId) const |
void | merge (const QTextFormat &other) |
int | objectIndex () const |
int | objectType () const |
operator QVariant () const | |
bool | operator!= (const QTextFormat &other) const |
QTextFormat & | operator= (const QTextFormat &other) |
bool | operator== (const QTextFormat &other) const |
QPen | penProperty (int propertyId) const |
QMap< int, QVariant > | properties () const |
QVariant | property (int propertyId) const |
int | propertyCount () const |
void | setBackground (const QBrush &brush) |
void | setForeground (const QBrush &brush) |
void | setLayoutDirection (Qt::LayoutDirection direction) |
void | setObjectIndex (int index) |
void | setObjectType (int type) |
void | setProperty (int propertyId, const QVariant &value) |
void | setProperty (int propertyId, const QVector< QTextLength > &value) |
QString | stringProperty (int propertyId) const |
void | swap (QTextFormat &other) |
QTextBlockFormat | toBlockFormat () const |
QTextCharFormat | toCharFormat () const |
QTextFrameFormat | toFrameFormat () const |
QTextImageFormat | toImageFormat () const |
QTextListFormat | toListFormat () const |
QTextTableCellFormat | toTableCellFormat () const |
QTextTableFormat | toTableFormat () const |
int | type () const |
Friends | |
class | QTextFormat |
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument.
A document is composed of a list of blocks, represented by QTextBlock objects. Each block can contain an item of some kind, such as a paragraph of text, a table, a list, or an image. Every block has an associated QTextBlockFormat that specifies its characteristics.
To cater for left-to-right and right-to-left languages you can set a block's direction with setDirection(). Paragraph alignment is set with setAlignment(). Margins are controlled by setTopMargin(), setBottomMargin(), setLeftMargin(), setRightMargin(). Overall indentation is set with setIndent(), the indentation of the first line with setTextIndent().
Line spacing is set with setLineHeight() and retrieved via lineHeight() and lineHeightType(). The types of line spacing available are in the LineHeightTypes enum.
Line breaking can be enabled and disabled with setNonBreakableLines().
The brush used to paint the paragraph's background is set with setBackground(), and other aspects of the text's appearance can be customized by using the setProperty() function with the OutlinePen
, ForegroundBrush
, and BackgroundBrush
QTextFormat::Property values.
If a text block is part of a list, it can also have a list format that is accessible with the listFormat() function.
This enum describes the various types of line spacing support paragraphs can have.
Constant | Value | Description |
---|---|---|
QTextBlockFormat::SingleHeight | 0 | This is the default line height: single spacing. |
QTextBlockFormat::ProportionalHeight | 1 | This sets the spacing proportional to the line (in percentage). For example, set to 200 for double spacing. |
QTextBlockFormat::FixedHeight | 2 | This sets the line height to a fixed line height (in pixels). |
QTextBlockFormat::MinimumHeight | 3 | This sets the minimum line height (in pixels). |
QTextBlockFormat::LineDistanceHeight | 4 | This adds the specified height between lines (in pixels). |
QTextBlockFormat::QTextBlockFormat | ( | ) |
Constructs a new QTextBlockFormat.
|
inline |
Returns the paragraph's alignment.
|
inline |
Returns the paragraph's bottom margin.
|
inline |
Returns the paragraph's indent.
|
inline |
Returns true if this block format is valid, otherwise returns false.
|
inline |
Returns the paragraph's left margin.
|
inline |
This returns the LineHeight property for the paragraph.
Returns the height of the lines in the paragraph based on the height of the script line given by scriptLineHeight and the specified scaling factor.
The value that is returned is also dependent on the given LineHeightType of the paragraph as well as the LineHeight setting that has been set for the paragraph.
The scaling is needed for heights that include a fixed number of pixels, to scale them appropriately for printing.
|
inline |
This returns the LineHeightType property of the paragraph.
|
inline |
Returns true if the lines in the paragraph are non-breakable, otherwise returns false.
|
inline |
Returns the currently set page break policy for the paragraph. The default is QTextFormat::PageBreak_Auto.
|
inline |
Returns the paragraph's right margin.
|
inline |
Sets the paragraph's alignment.
|
inline |
Sets the paragraph's bottom margin.
|
inline |
Sets the paragraph's indent. Margins are set independently of indentation with setLeftMargin() and setTextIndent(). The indentation is an integer that is multiplied with the document-wide standard indent, resulting in the actual indent of the paragraph.
|
inline |
Sets the paragraph's left margin. Indentation can be applied separately with setIndent().
|
inline |
Sets the line height for the paragraph to the value given by height which is dependent on heightType in the way described by the LineHeightTypes enum.
|
inline |
If b is true, the lines in the paragraph are treated as non-breakable, otherwise they are breakable.
|
inline |
Sets the page break policy for the paragraph to policy.
|
inline |
Sets the paragraph's right margin.
void QTextBlockFormat::setTabPositions | ( | const QList< QTextOption::Tab > & | tabs | ) |
Sets the tab positions for the text block to those specified by tabs.
|
inline |
Sets the indent for the first line in the block. This allows the first line of a paragraph to be indented differently to the other lines, enhancing the readability of the text.
|
inline |
Sets the paragraph's top margin.
QList< QTextOption::Tab > QTextBlockFormat::tabPositions | ( | ) | const |
Returns a list of tab positions defined for the text block.
|
inline |
Returns the paragraph's text indent.
|
inline |
Returns the paragraph's top margin.