Qt 4.8
|
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument. More...
#include <qtextformat.h>
Public Functions | |
Qt::Alignment | alignment () const |
Returns the paragraph's alignment. More... | |
qreal | bottomMargin () const |
Returns the paragraph's bottom margin. More... | |
int | indent () const |
Returns the paragraph's indent. More... | |
bool | isValid () const |
Returns true if this block format is valid; otherwise returns false. More... | |
qreal | leftMargin () const |
Returns the paragraph's left margin. More... | |
qreal | lineHeight (qreal scriptLineHeight, qreal scaling) const |
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. More... | |
qreal | lineHeight () const |
This returns the LineHeight property for the paragraph. More... | |
int | lineHeightType () const |
This returns the LineHeightType property of the paragraph. More... | |
bool | nonBreakableLines () const |
Returns true if the lines in the paragraph are non-breakable; otherwise returns false. More... | |
PageBreakFlags | pageBreakPolicy () const |
Returns the currently set page break policy for the paragraph. More... | |
QTextBlockFormat () | |
Constructs a new QTextBlockFormat. More... | |
qreal | rightMargin () const |
Returns the paragraph's right margin. More... | |
void | setAlignment (Qt::Alignment alignment) |
Sets the paragraph's alignment. More... | |
void | setBottomMargin (qreal margin) |
Sets the paragraph's bottom margin. More... | |
void | setIndent (int indent) |
Sets the paragraph's indentation. More... | |
void | setLeftMargin (qreal margin) |
Sets the paragraph's left margin. More... | |
void | setLineHeight (qreal height, int heightType) |
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. More... | |
void | setNonBreakableLines (bool b) |
If b is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable. More... | |
void | setPageBreakPolicy (PageBreakFlags flags) |
Sets the page break policy for the paragraph to policy. More... | |
void | setRightMargin (qreal margin) |
Sets the paragraph's right margin. More... | |
void | setTabPositions (const QList< QTextOption::Tab > &tabs) |
Sets the tab positions for the text block to those specified by tabs. More... | |
void | setTextIndent (qreal aindent) |
Sets the indent for the first line in the block. More... | |
void | setTopMargin (qreal margin) |
Sets the paragraph's top margin. More... | |
QList< QTextOption::Tab > | tabPositions () const |
Returns a list of tab positions defined for the text block. More... | |
qreal | textIndent () const |
Returns the paragraph's text indent. More... | |
qreal | topMargin () const |
Returns the paragraph's top margin. More... | |
Public Functions inherited from QTextFormat | |
QBrush | background () const |
Returns the brush used to paint the document's background. More... | |
bool | boolProperty (int propertyId) const |
Returns the value of the property specified by propertyId. More... | |
QBrush | brushProperty (int propertyId) const |
Returns the value of the property given by propertyId; if the property isn't of QVariant::Brush type, Qt::NoBrush is returned instead. More... | |
void | clearBackground () |
Clears the brush used to paint the document's background. More... | |
void | clearForeground () |
Clears the brush used to paint the document's foreground. More... | |
void | clearProperty (int propertyId) |
Clears the value of the property given by propertyId. More... | |
QColor | colorProperty (int propertyId) const |
Returns the value of the property given by propertyId; if the property isn't of QVariant::Color type, an invalid color is returned instead. More... | |
qreal | doubleProperty (int propertyId) const |
Returns the value of the property specified by propertyId. More... | |
QBrush | foreground () const |
Returns the brush used to render foreground details, such as text, frame outlines, and table borders. More... | |
bool | hasProperty (int propertyId) const |
Returns true if the text format has a property with the given propertyId; otherwise returns false. More... | |
int | intProperty (int propertyId) const |
Returns the value of the property specified by propertyId. More... | |
bool | isBlockFormat () const |
Returns true if this text format is a BlockFormat ; otherwise returns false. More... | |
bool | isCharFormat () const |
Returns true if this text format is a CharFormat ; otherwise returns false. More... | |
bool | isFrameFormat () const |
Returns true if this text format is a FrameFormat ; otherwise returns false. More... | |
bool | isImageFormat () const |
Returns true if this text format is an image format; otherwise returns false. More... | |
bool | isListFormat () const |
Returns true if this text format is a ListFormat ; otherwise returns false. More... | |
bool | isTableCellFormat () const |
Returns true if this text format is a TableCellFormat ; otherwise returns false. More... | |
bool | isTableFormat () const |
Returns true if this text format is a TableFormat ; otherwise returns false. More... | |
bool | isValid () const |
Returns true if the format is valid (i. More... | |
Qt::LayoutDirection | layoutDirection () const |
Returns the document's layout direction. More... | |
QTextLength | lengthProperty (int propertyId) const |
Returns the value of the property given by propertyId. More... | |
QVector< QTextLength > | lengthVectorProperty (int propertyId) const |
Returns the value of the property given by propertyId. More... | |
void | merge (const QTextFormat &other) |
Merges the other format with this format; where there are conflicts the other format takes precedence. More... | |
int | objectIndex () const |
Returns the index of the format object, or -1 if the format object is invalid. More... | |
int | objectType () const |
Returns the text format's object type. More... | |
operator QVariant () const | |
Returns the text format as a QVariant. More... | |
bool | operator!= (const QTextFormat &rhs) const |
Returns true if this text format is different from the other text format. More... | |
QTextFormat & | operator= (const QTextFormat &rhs) |
Assigns the other text format to this text format, and returns a reference to this text format. More... | |
bool | operator== (const QTextFormat &rhs) const |
Returns true if this text format is the same as the other text format. More... | |
QPen | penProperty (int propertyId) const |
Returns the value of the property given by propertyId; if the property isn't of QVariant::Pen type, Qt::NoPen is returned instead. More... | |
QMap< int, QVariant > | properties () const |
Returns a map with all properties of this text format. More... | |
QVariant | property (int propertyId) const |
Returns the property specified by the given propertyId. More... | |
int | propertyCount () const |
Returns the number of properties stored in the format. More... | |
QTextFormat () | |
Creates a new text format with an InvalidFormat . More... | |
QTextFormat (int type) | |
Creates a new text format of the given type. More... | |
QTextFormat (const QTextFormat &rhs) | |
Creates a new text format with the same attributes as the other text format. More... | |
void | setBackground (const QBrush &brush) |
Sets the brush use to paint the document's background to the brush specified. More... | |
void | setForeground (const QBrush &brush) |
Sets the foreground brush to the specified brush. More... | |
void | setLayoutDirection (Qt::LayoutDirection direction) |
Sets the document's layout direction to the specified direction. More... | |
void | setObjectIndex (int object) |
Sets the format object's object index. More... | |
void | setObjectType (int type) |
Sets the text format's object type to type. More... | |
void | setProperty (int propertyId, const QVariant &value) |
Sets the property specified by the propertyId to the given value. More... | |
void | setProperty (int propertyId, const QVector< QTextLength > &lengths) |
Sets the value of the property given by propertyId to value. More... | |
QString | stringProperty (int propertyId) const |
Returns the value of the property given by propertyId; if the property isn't of QVariant::String type, an empty string is returned instead. More... | |
QTextBlockFormat | toBlockFormat () const |
Returns this format as a block format. More... | |
QTextCharFormat | toCharFormat () const |
Returns this format as a character format. More... | |
QTextFrameFormat | toFrameFormat () const |
Returns this format as a frame format. More... | |
QTextImageFormat | toImageFormat () const |
Returns this format as an image format. More... | |
QTextListFormat | toListFormat () const |
Returns this format as a list format. More... | |
QTextTableCellFormat | toTableCellFormat () const |
Returns this format as a table cell format. More... | |
QTextTableFormat | toTableFormat () const |
Returns this format as a table format. More... | |
int | type () const |
Returns the type of this format. More... | |
~QTextFormat () | |
Destroys this text format. More... | |
Protected Functions | |
QTextBlockFormat (const QTextFormat &fmt) | |
Creates a new block format with the same attributes as the given text format. More... | |
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.
Definition at line 545 of file qtextformat.h.
This enum describes the various types of line spacing support paragraphs can have.
Enumerator | |
---|---|
SingleHeight | |
ProportionalHeight | |
FixedHeight | |
MinimumHeight | |
LineDistanceHeight |
Definition at line 548 of file qtextformat.h.
QTextBlockFormat::QTextBlockFormat | ( | ) |
Constructs a new QTextBlockFormat.
Definition at line 2199 of file qtextformat.cpp.
|
explicitprotected |
Creates a new block format with the same attributes as the given text format.
Definition at line 2211 of file qtextformat.cpp.
|
inline |
Returns the paragraph's alignment.
Definition at line 561 of file qtextformat.h.
Referenced by QTextHtmlParser::applyAttributes(), QAccessibleTextWidget::attributes(), QTextHtmlExporter::emitBlockAttributes(), QTextHtmlParserNode::initializeProperties(), QTextDocumentLayoutPrivate::layoutBlock(), QTextHtmlImporter::scanTable(), and QTextOdfWriter::writeBlockFormat().
|
inline |
Returns the paragraph's bottom margin.
Definition at line 571 of file qtextformat.h.
Referenced by QTextHtmlExporter::emitBlockAttributes(), QTextDocumentLayoutPrivate::layoutBlock(), QTextDocumentLayoutPrivate::layoutFlow(), QTextHtmlImporter::processBlockNode(), and QTextOdfWriter::writeBlockFormat().
|
inline |
Returns the paragraph's indent.
Definition at line 590 of file qtextformat.h.
Referenced by QTextDocumentLayoutPrivate::blockIndent(), QTextControlPrivate::createAutoBulletList(), QTextEditPrivate::createAutoBulletList(), QTextHtmlExporter::emitBlockAttributes(), QTextControlPrivate::indent(), QTextControlPrivate::keyPressEvent(), QPlainTextEdit::keyReleaseEvent(), QTextEdit::keyReleaseEvent(), QTextControlPrivate::outdent(), QTextList::remove(), and QTextOdfWriter::writeBlockFormat().
|
inline |
Returns true if this block format is valid; otherwise returns false.
Definition at line 558 of file qtextformat.h.
Referenced by QTextDocumentPrivate::setBlockFormat().
|
inline |
Returns the paragraph's left margin.
Definition at line 576 of file qtextformat.h.
Referenced by QTextHtmlExporter::emitBlockAttributes(), QTextDocumentLayoutPrivate::layoutBlock(), QTextHtmlImporter::processBlockNode(), and QTextOdfWriter::writeBlockFormat().
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.
Definition at line 625 of file qtextformat.h.
Referenced by getLineHeightParams().
|
inline |
This returns the LineHeight property for the paragraph.
Definition at line 596 of file qtextformat.h.
|
inline |
This returns the LineHeightType property of the paragraph.
Definition at line 598 of file qtextformat.h.
Referenced by getLineHeightParams().
|
inline |
Returns true if the lines in the paragraph are non-breakable; otherwise returns false.
Definition at line 603 of file qtextformat.h.
Referenced by QTextHtmlExporter::emitBlock(), QTextDocumentLayoutPrivate::layoutBlock(), and QTextOdfWriter::writeBlockFormat().
|
inline |
Returns the currently set page break policy for the paragraph.
The default is QTextFormat::PageBreak_Auto.
Definition at line 608 of file qtextformat.h.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), QTextHtmlExporter::emitBlockAttributes(), QTextHtmlImporter::import(), QTextDocumentLayoutPrivate::layoutFlow(), QTextHtmlImporter::scanTable(), and QTextOdfWriter::writeBlockFormat().
|
inline |
Returns the paragraph's right margin.
Definition at line 581 of file qtextformat.h.
Referenced by QTextHtmlExporter::emitBlockAttributes(), QTextDocumentLayoutPrivate::layoutBlock(), QTextHtmlImporter::processBlockNode(), and QTextOdfWriter::writeBlockFormat().
|
inline |
Sets the paragraph's alignment.
Definition at line 619 of file qtextformat.h.
Referenced by QTextHtmlParser::applyAttributes(), QSplashScreen::drawContents(), QTextHtmlParserNode::initializeProperties(), and QTextEdit::setAlignment().
|
inline |
Sets the paragraph's bottom margin.
Definition at line 569 of file qtextformat.h.
Referenced by QTextHtmlImporter::processBlockNode(), and QTextHtmlImporter::processSpecialNodes().
|
inline |
Sets the paragraph's indentation.
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.
Definition at line 622 of file qtextformat.h.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), QTextControlPrivate::createAutoBulletList(), QTextEditPrivate::createAutoBulletList(), QTextHtmlImporter::import(), QTextControlPrivate::indent(), QTextControlPrivate::keyPressEvent(), QPlainTextEdit::keyReleaseEvent(), QTextEdit::keyReleaseEvent(), QTextControlPrivate::outdent(), QTextHtmlImporter::processBlockNode(), and QTextList::remove().
|
inline |
Sets the paragraph's left margin.
Indentation can be applied separately with setIndent().
Definition at line 574 of file qtextformat.h.
Referenced by QTextHtmlImporter::processBlockNode().
|
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.
Definition at line 593 of file qtextformat.h.
Referenced by QTextHtmlParserNode::applyCssDeclarations().
|
inline |
If b is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable.
Definition at line 601 of file qtextformat.h.
Referenced by QTextHtmlImporter::processBlockNode().
|
inline |
Sets the page break policy for the paragraph to policy.
Definition at line 606 of file qtextformat.h.
Referenced by QTextHtmlParserNode::applyCssDeclarations(), and QTextHtmlImporter::import().
|
inline |
Sets the paragraph's right margin.
Definition at line 579 of file qtextformat.h.
Referenced by QTextHtmlImporter::processBlockNode().
void QTextBlockFormat::setTabPositions | ( | const QList< QTextOption::Tab > & | tabs | ) |
Sets the tab positions for the text block to those specified by tabs.
Definition at line 2226 of file qtextformat.cpp.
|
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.
Definition at line 584 of file qtextformat.h.
Referenced by QTextHtmlParserNode::applyCssDeclarations().
|
inline |
Sets the paragraph's top margin.
Definition at line 564 of file qtextformat.h.
Referenced by QTextHtmlImporter::processBlockNode(), and QTextHtmlImporter::processSpecialNodes().
QList< QTextOption::Tab > QTextBlockFormat::tabPositions | ( | ) | const |
Returns a list of tab positions defined for the text block.
Definition at line 2248 of file qtextformat.cpp.
Referenced by QTextDocumentLayoutPrivate::layoutBlock(), and QTextOdfWriter::writeBlockFormat().
|
inline |
Returns the paragraph's text indent.
Definition at line 586 of file qtextformat.h.
Referenced by QTextHtmlExporter::emitBlockAttributes(), QTextDocumentLayoutPrivate::layoutBlock(), and QTextOdfWriter::writeBlockFormat().
|
inline |
Returns the paragraph's top margin.
Definition at line 566 of file qtextformat.h.
Referenced by QTextHtmlExporter::emitBlockAttributes(), QTextDocumentLayoutPrivate::layoutBlock(), QTextDocumentLayoutPrivate::layoutFlow(), QTextHtmlImporter::processBlockNode(), and QTextOdfWriter::writeBlockFormat().
|
friend |
Definition at line 616 of file qtextformat.h.