Qt 4.8
Public Types | Public Functions | Protected Functions | Friends | List of all members
QTextBlockFormat Class Reference

The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument. More...

#include <qtextformat.h>

Inheritance diagram for QTextBlockFormat:
QTextFormat

Public Types

enum  LineHeightTypes {
  SingleHeight = 0, ProportionalHeight = 1, FixedHeight = 2, MinimumHeight = 3,
  LineDistanceHeight = 4
}
 This enum describes the various types of line spacing support paragraphs can have. More...
 
- Public Types inherited from QTextFormat
enum  FormatType {
  InvalidFormat = -1, BlockFormat = 1, CharFormat = 2, ListFormat = 3,
  TableFormat = 4, FrameFormat = 5, UserFormat = 100
}
 This enum describes the text item a QTextFormat object is formatting. More...
 
enum  ObjectTypes {
  NoObject, ImageObject, TableObject, TableCellObject,
  UserObject = 0x1000
}
 This enum describes what kind of QTextObject this format is associated with. More...
 
enum  PageBreakFlag { PageBreak_Auto = 0, PageBreak_AlwaysBefore = 0x001, PageBreak_AlwaysAfter = 0x010 }
 This enum describes how page breaking is performed when printing. More...
 
enum  Property {
  ObjectIndex = 0x0, CssFloat = 0x0800, LayoutDirection = 0x0801, OutlinePen = 0x810,
  BackgroundBrush = 0x820, ForegroundBrush = 0x821, BackgroundImageUrl = 0x823, BlockAlignment = 0x1010,
  BlockTopMargin = 0x1030, BlockBottomMargin = 0x1031, BlockLeftMargin = 0x1032, BlockRightMargin = 0x1033,
  TextIndent = 0x1034, TabPositions = 0x1035, BlockIndent = 0x1040, LineHeight = 0x1048,
  LineHeightType = 0x1049, BlockNonBreakableLines = 0x1050, BlockTrailingHorizontalRulerWidth = 0x1060, FirstFontProperty = 0x1FE0,
  FontCapitalization = FirstFontProperty, FontLetterSpacing = 0x1FE1, FontWordSpacing = 0x1FE2, FontStyleHint = 0x1FE3,
  FontStyleStrategy = 0x1FE4, FontKerning = 0x1FE5, FontHintingPreference = 0x1FE6, FontFamily = 0x2000,
  FontPointSize = 0x2001, FontSizeAdjustment = 0x2002, FontSizeIncrement = FontSizeAdjustment, FontWeight = 0x2003,
  FontItalic = 0x2004, FontUnderline = 0x2005, FontOverline = 0x2006, FontStrikeOut = 0x2007,
  FontFixedPitch = 0x2008, FontPixelSize = 0x2009, LastFontProperty = FontPixelSize, TextUnderlineColor = 0x2010,
  TextVerticalAlignment = 0x2021, TextOutline = 0x2022, TextUnderlineStyle = 0x2023, TextToolTip = 0x2024,
  IsAnchor = 0x2030, AnchorHref = 0x2031, AnchorName = 0x2032, ObjectType = 0x2f00,
  ListStyle = 0x3000, ListIndent = 0x3001, ListNumberPrefix = 0x3002, ListNumberSuffix = 0x3003,
  FrameBorder = 0x4000, FrameMargin = 0x4001, FramePadding = 0x4002, FrameWidth = 0x4003,
  FrameHeight = 0x4004, FrameTopMargin = 0x4005, FrameBottomMargin = 0x4006, FrameLeftMargin = 0x4007,
  FrameRightMargin = 0x4008, FrameBorderBrush = 0x4009, FrameBorderStyle = 0x4010, TableColumns = 0x4100,
  TableColumnWidthConstraints = 0x4101, TableCellSpacing = 0x4102, TableCellPadding = 0x4103, TableHeaderRowCount = 0x4104,
  TableCellRowSpan = 0x4810, TableCellColumnSpan = 0x4811, TableCellTopPadding = 0x4812, TableCellBottomPadding = 0x4813,
  TableCellLeftPadding = 0x4814, TableCellRightPadding = 0x4815, ImageName = 0x5000, ImageWidth = 0x5010,
  ImageHeight = 0x5011, FullWidthSelection = 0x06000, PageBreakPolicy = 0x7000, UserProperty = 0x100000
}
 This enum describes the different properties a format can have. More...
 

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::TabtabPositions () 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< QTextLengthlengthVectorProperty (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...
 
QTextFormatoperator= (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, QVariantproperties () 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
 

Detailed Description

The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument.

Note
This class or function is reentrant.

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.

See also
QTextBlock, QTextCharFormat

Definition at line 545 of file qtextformat.h.

Enumerations

◆ LineHeightTypes

This enum describes the various types of line spacing support paragraphs can have.

Since
4.8
  • SingleHeight This is the default line height: single spacing.
  • ProportionalHeight This sets the spacing proportional to the line (in percentage). For example, set to 200 for double spacing.
  • FixedHeight This sets the line height to a fixed line height (in pixels).
  • MinimumHeight This sets the minimum line height (in pixels).
  • LineDistanceHeight This adds the specified height between lines (in pixels).
See also
lineHeight(), lineHeightType(), setLineHeight()
Enumerator
SingleHeight 
ProportionalHeight 
FixedHeight 
MinimumHeight 
LineDistanceHeight 

Definition at line 548 of file qtextformat.h.

Constructors and Destructors

◆ QTextBlockFormat() [1/2]

QTextBlockFormat::QTextBlockFormat ( )

Constructs a new QTextBlockFormat.

Definition at line 2199 of file qtextformat.cpp.

QTextFormat()
Creates a new text format with an InvalidFormat.

◆ QTextBlockFormat() [2/2]

QTextBlockFormat::QTextBlockFormat ( const QTextFormat other)
explicitprotected

Creates a new block format with the same attributes as the given text format.

Warning
This function is not part of the public interface.

Definition at line 2211 of file qtextformat.cpp.

2212  : QTextFormat(fmt)
2213 {
2214 }
QTextFormat()
Creates a new text format with an InvalidFormat.

Functions

◆ alignment()

Qt::Alignment QTextBlockFormat::alignment ( ) const
inline

Returns the paragraph's alignment.

See also
setAlignment()

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

562  { int a = intProperty(BlockAlignment); if (a == 0) a = Qt::AlignLeft; return QFlag(a); }
The QFlag class is a helper data type for QFlags.
Definition: qglobal.h:2289
long ASN1_INTEGER_get ASN1_INTEGER * a
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ bottomMargin()

qreal QTextBlockFormat::bottomMargin ( ) const
inline

Returns the paragraph's bottom margin.

See also
setBottomMargin() topMargin()

Definition at line 571 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitBlockAttributes(), QTextDocumentLayoutPrivate::layoutBlock(), QTextDocumentLayoutPrivate::layoutFlow(), QTextHtmlImporter::processBlockNode(), and QTextOdfWriter::writeBlockFormat().

572  { return doubleProperty(BlockBottomMargin); }
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ indent()

int QTextBlockFormat::indent ( ) const
inline

◆ isValid()

QTextBlockFormat::isValid ( ) const
inline

Returns true if this block format is valid; otherwise returns false.

Definition at line 558 of file qtextformat.h.

Referenced by QTextDocumentPrivate::setBlockFormat().

558 { return isBlockFormat(); }
bool isBlockFormat() const
Returns true if this text format is a BlockFormat; otherwise returns false.
Definition: qtextformat.h:319

◆ leftMargin()

qreal QTextBlockFormat::leftMargin ( ) const
inline

Returns the paragraph's left margin.

See also
setLeftMargin() rightMargin() indent()

Definition at line 576 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitBlockAttributes(), QTextDocumentLayoutPrivate::layoutBlock(), QTextHtmlImporter::processBlockNode(), and QTextOdfWriter::writeBlockFormat().

577  { return doubleProperty(BlockLeftMargin); }
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ lineHeight() [1/2]

qreal QTextBlockFormat::lineHeight ( qreal  scriptLineHeight,
qreal  scaling = 1.0 
) const
inline

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.

Since
4.8

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.

See also
LineHeightTypes, setLineHeight(), lineHeightType()

Definition at line 625 of file qtextformat.h.

Referenced by getLineHeightParams().

626 {
627  switch(intProperty(LineHeightType)) {
628  case SingleHeight:
629  return(scriptLineHeight);
630  case ProportionalHeight:
631  return(scriptLineHeight * doubleProperty(LineHeight) / 100.0);
632  case FixedHeight:
633  return(doubleProperty(LineHeight) * scaling);
634  case MinimumHeight:
635  return(qMax(scriptLineHeight, doubleProperty(LineHeight) * scaling));
636  case LineDistanceHeight:
637  return(scriptLineHeight + doubleProperty(LineHeight) * scaling);
638  }
639  return(0);
640 }
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ lineHeight() [2/2]

qreal QTextBlockFormat::lineHeight ( ) const
inline

This returns the LineHeight property for the paragraph.

Since
4.8
See also
LineHeightTypes, setLineHeight(), lineHeightType()

Definition at line 596 of file qtextformat.h.

597  { return doubleProperty(LineHeight); }
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ lineHeightType()

qreal QTextBlockFormat::lineHeightType ( ) const
inline

This returns the LineHeightType property of the paragraph.

Since
4.8
See also
LineHeightTypes, setLineHeight(), lineHeight()

Definition at line 598 of file qtextformat.h.

Referenced by getLineHeightParams().

599  { return intProperty(LineHeightType); }
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ nonBreakableLines()

bool QTextBlockFormat::nonBreakableLines ( ) const
inline

Returns true if the lines in the paragraph are non-breakable; otherwise returns false.

See also
setNonBreakableLines()

Definition at line 603 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitBlock(), QTextDocumentLayoutPrivate::layoutBlock(), and QTextOdfWriter::writeBlockFormat().

bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ pageBreakPolicy()

QTextFormat::PageBreakFlags QTextBlockFormat::pageBreakPolicy ( ) const
inline

Returns the currently set page break policy for the paragraph.

Since
4.2

The default is QTextFormat::PageBreak_Auto.

See also
setPageBreakPolicy()

Definition at line 608 of file qtextformat.h.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), QTextHtmlExporter::emitBlockAttributes(), QTextHtmlImporter::import(), QTextDocumentLayoutPrivate::layoutFlow(), QTextHtmlImporter::scanTable(), and QTextOdfWriter::writeBlockFormat().

609  { return PageBreakFlags(intProperty(PageBreakPolicy)); }
int intProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ rightMargin()

qreal QTextBlockFormat::rightMargin ( ) const
inline

Returns the paragraph's right margin.

See also
setRightMargin() leftMargin()

Definition at line 581 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitBlockAttributes(), QTextDocumentLayoutPrivate::layoutBlock(), QTextHtmlImporter::processBlockNode(), and QTextOdfWriter::writeBlockFormat().

582  { return doubleProperty(BlockRightMargin); }
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ setAlignment()

void QTextBlockFormat::setAlignment ( Qt::Alignment  alignment)
inline

Sets the paragraph's alignment.

See also
alignment()

Definition at line 619 of file qtextformat.h.

Referenced by QTextHtmlParser::applyAttributes(), QSplashScreen::drawContents(), QTextHtmlParserNode::initializeProperties(), and QTextEdit::setAlignment().

620 { setProperty(BlockAlignment, int(aalignment)); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setBottomMargin()

void QTextBlockFormat::setBottomMargin ( qreal  margin)
inline

Sets the paragraph's bottom margin.

See also
bottomMargin() setTopMargin() setLeftMargin() setRightMargin()

Definition at line 569 of file qtextformat.h.

Referenced by QTextHtmlImporter::processBlockNode(), and QTextHtmlImporter::processSpecialNodes().

570  { setProperty(BlockBottomMargin, margin); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setIndent()

void QTextBlockFormat::setIndent ( int  indentation)
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.

See also
indent() QTextDocument::indentWidth()

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

623 { setProperty(BlockIndent, aindent); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setLeftMargin()

void QTextBlockFormat::setLeftMargin ( qreal  margin)
inline

Sets the paragraph's left margin.

Indentation can be applied separately with setIndent().

See also
leftMargin() setRightMargin() setTopMargin() setBottomMargin()

Definition at line 574 of file qtextformat.h.

Referenced by QTextHtmlImporter::processBlockNode().

575  { setProperty(BlockLeftMargin, margin); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setLineHeight()

void QTextBlockFormat::setLineHeight ( qreal  height,
int  heightType 
)
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.

Since
4.8
See also
LineHeightTypes, lineHeight(), lineHeightType()

Definition at line 593 of file qtextformat.h.

Referenced by QTextHtmlParserNode::applyCssDeclarations().

594  { setProperty(LineHeight, height); setProperty(LineHeightType, heightType); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setNonBreakableLines()

void QTextBlockFormat::setNonBreakableLines ( bool  b)
inline

If b is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable.

See also
nonBreakableLines()

Definition at line 601 of file qtextformat.h.

Referenced by QTextHtmlImporter::processBlockNode().

void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setPageBreakPolicy()

void QTextBlockFormat::setPageBreakPolicy ( PageBreakFlags  policy)
inline

Sets the page break policy for the paragraph to policy.

Since
4.2
See also
pageBreakPolicy()

Definition at line 606 of file qtextformat.h.

Referenced by QTextHtmlParserNode::applyCssDeclarations(), and QTextHtmlImporter::import().

607  { setProperty(PageBreakPolicy, int(flags)); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setRightMargin()

void QTextBlockFormat::setRightMargin ( qreal  margin)
inline

Sets the paragraph's right margin.

See also
rightMargin() setLeftMargin() setTopMargin() setBottomMargin()

Definition at line 579 of file qtextformat.h.

Referenced by QTextHtmlImporter::processBlockNode().

580  { setProperty(BlockRightMargin, margin); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setTabPositions()

void QTextBlockFormat::setTabPositions ( const QList< QTextOption::Tab > &  tabs)

Sets the tab positions for the text block to those specified by tabs.

Since
4.4
See also
tabPositions()

Definition at line 2226 of file qtextformat.cpp.

2227 {
2228  QList<QVariant> list;
2230  while (iter != tabs.constEnd()) {
2231  QVariant v;
2232  v.setValue<QTextOption::Tab>(*iter);
2233  list.append(v);
2234  ++iter;
2235  }
2236  setProperty(TabPositions, list);
2237 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
void setValue(const T &value)
Stores a copy of value.
Definition: qvariant.h:527
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
Each tab definition is represented by this struct.
Definition: qtextoption.h:69

◆ setTextIndent()

void QTextBlockFormat::setTextIndent ( qreal  indent)
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.

See also
textIndent() setLeftMargin() setRightMargin() setTopMargin() setBottomMargin()

Definition at line 584 of file qtextformat.h.

Referenced by QTextHtmlParserNode::applyCssDeclarations().

585  { setProperty(TextIndent, aindent); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ setTopMargin()

void QTextBlockFormat::setTopMargin ( qreal  margin)
inline

Sets the paragraph's top margin.

See also
topMargin() setBottomMargin() setLeftMargin() setRightMargin()

Definition at line 564 of file qtextformat.h.

Referenced by QTextHtmlImporter::processBlockNode(), and QTextHtmlImporter::processSpecialNodes().

565  { setProperty(BlockTopMargin, margin); }
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.

◆ tabPositions()

QList< QTextOption::Tab > QTextBlockFormat::tabPositions ( ) const

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

Since
4.4
See also
setTabPositions()

Definition at line 2248 of file qtextformat.cpp.

Referenced by QTextDocumentLayoutPrivate::layoutBlock(), and QTextOdfWriter::writeBlockFormat().

2249 {
2251  if(variant.isNull())
2252  return QList<QTextOption::Tab>();
2253  QList<QTextOption::Tab> answer;
2255  QList<QVariant>::Iterator iter = variantsList.begin();
2256  while(iter != variantsList.end()) {
2257  answer.append( qvariant_cast<QTextOption::Tab>(*iter));
2258  ++iter;
2259  }
2260  return answer;
2261 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
QVariant property(int propertyId) const
Returns the property specified by the given propertyId.
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
const char * variant

◆ textIndent()

qreal QTextBlockFormat::textIndent ( ) const
inline

Returns the paragraph's text indent.

See also
setTextIndent()

Definition at line 586 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitBlockAttributes(), QTextDocumentLayoutPrivate::layoutBlock(), and QTextOdfWriter::writeBlockFormat().

587  { return doubleProperty(TextIndent); }
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.

◆ topMargin()

qreal QTextBlockFormat::topMargin ( ) const
inline

Returns the paragraph's top margin.

See also
setTopMargin() bottomMargin()

Definition at line 566 of file qtextformat.h.

Referenced by QTextHtmlExporter::emitBlockAttributes(), QTextDocumentLayoutPrivate::layoutBlock(), QTextDocumentLayoutPrivate::layoutFlow(), QTextHtmlImporter::processBlockNode(), and QTextOdfWriter::writeBlockFormat().

567  { return doubleProperty(BlockTopMargin); }
qreal doubleProperty(int propertyId) const
Returns the value of the property specified by propertyId.

Friends and Related Functions

◆ QTextFormat

friend class QTextFormat
friend

Definition at line 616 of file qtextformat.h.


The documentation for this class was generated from the following files: