<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QTextBlockFormat Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QTextBlockFormat Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QTextBlockFormat class provides formatting information for blocks of text in a <a href="qtextdocument.html">QTextDocument</a>. <a href="#details">More...</a></p> <p>Inherits <a href="qtextformat.html">QTextFormat</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qtextblockformat.html#LineHeightTypes-enum">LineHeightTypes</a></b> { SingleHeight, ProportionalHeight, FixedHeight, MinimumHeight, LineDistanceHeight }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtextblockformat.html#QTextBlockFormat">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#QTextBlockFormat-2">__init__</a></b> (<i>self</i>, QTextBlockFormat)</li><li><div class="fn" />Qt.Alignment <b><a href="qtextblockformat.html#alignment">alignment</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextblockformat.html#bottomMargin">bottomMargin</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextblockformat.html#indent">indent</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextblockformat.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextblockformat.html#leftMargin">leftMargin</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextblockformat.html#lineHeight">lineHeight</a></b> (<i>self</i>, float <i>scriptLineHeight</i>, float <i>scaling</i>)</li><li><div class="fn" />float <b><a href="qtextblockformat.html#lineHeight-2">lineHeight</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextblockformat.html#lineHeightType">lineHeightType</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextblockformat.html#nonBreakableLines">nonBreakableLines</a></b> (<i>self</i>)</li><li><div class="fn" />QTextFormat.PageBreakFlags <b><a href="qtextblockformat.html#pageBreakPolicy">pageBreakPolicy</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextblockformat.html#rightMargin">rightMargin</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setAlignment">setAlignment</a></b> (<i>self</i>, Qt.Alignment <i>aalignment</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setBottomMargin">setBottomMargin</a></b> (<i>self</i>, float <i>margin</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setIndent">setIndent</a></b> (<i>self</i>, int <i>aindent</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setLeftMargin">setLeftMargin</a></b> (<i>self</i>, float <i>margin</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setLineHeight">setLineHeight</a></b> (<i>self</i>, float <i>height</i>, int <i>heightType</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setNonBreakableLines">setNonBreakableLines</a></b> (<i>self</i>, bool <i>b</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setPageBreakPolicy">setPageBreakPolicy</a></b> (<i>self</i>, QTextFormat.PageBreakFlags <i>flags</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setRightMargin">setRightMargin</a></b> (<i>self</i>, float <i>margin</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setTabPositions">setTabPositions</a></b> (<i>self</i>, list-of-QTextOption.Tab <i>tabs</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setTextIndent">setTextIndent</a></b> (<i>self</i>, float <i>margin</i>)</li><li><div class="fn" /><b><a href="qtextblockformat.html#setTopMargin">setTopMargin</a></b> (<i>self</i>, float <i>margin</i>)</li><li><div class="fn" />list-of-QTextOption.Tab <b><a href="qtextblockformat.html#tabPositions">tabPositions</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextblockformat.html#textIndent">textIndent</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qtextblockformat.html#topMargin">topMargin</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTextBlockFormat class provides formatting information for blocks of text in a <a href="qtextdocument.html">QTextDocument</a>.</p> <p>A document is composed of a list of blocks, represented by <a href="qtextblock.html">QTextBlock</a> 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.</p> <p>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 <a href="qtextblockformat.html#setAlignment">setAlignment</a>(). Margins are controlled by <a href="qtextblockformat.html#setTopMargin">setTopMargin</a>(), <a href="qtextblockformat.html#setBottomMargin">setBottomMargin</a>(), <a href="qtextblockformat.html#setLeftMargin">setLeftMargin</a>(), <a href="qtextblockformat.html#setRightMargin">setRightMargin</a>(). Overall indentation is set with <a href="qtextblockformat.html#setIndent">setIndent</a>(), the indentation of the first line with <a href="qtextblockformat.html#setTextIndent">setTextIndent</a>().</p> <p>Line spacing is set with <a href="qtextblockformat.html#setLineHeight">setLineHeight</a>() and retrieved via <a href="qtextblockformat.html#lineHeight">lineHeight</a>() and <a href="qtextblockformat.html#lineHeightType">lineHeightType</a>(). The types of line spacing available are in the <a href="qtextblockformat.html#LineHeightTypes-enum">LineHeightTypes</a> enum.</p> <p>Line breaking can be enabled and disabled with <a href="qtextblockformat.html#setNonBreakableLines">setNonBreakableLines</a>().</p> <p>The brush used to paint the paragraph's background is set with <a href="qtextformat.html#setBackground">setBackground()</a>, and other aspects of the text's appearance can be customized by using the <a href="qtextformat.html#setProperty">setProperty()</a> function with the <tt>OutlinePen</tt>, <tt>ForegroundBrush</tt>, and <tt>BackgroundBrush</tt> <a href="qtextformat.html#Property-enum">QTextFormat.Property</a> values.</p> <p>If a text block is part of a list, it can also have a list format that is accessible with the listFormat() function.</p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="LineHeightTypes-enum" />QTextBlockFormat.LineHeightTypes</h3><p>This enum describes the various types of line spacing support paragraphs can have.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QTextBlockFormat.SingleHeight</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">This is the default line height: single spacing.</td> </tr> <tr> <td class="topAlign"> <tt>QTextBlockFormat.ProportionalHeight</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">This sets the spacing proportional to the line (in percentage). For example, set to 200 for double spacing.</td> </tr> <tr> <td class="topAlign"><tt>QTextBlockFormat.FixedHeight</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">This sets the line height to a fixed line height (in pixels).</td> </tr> <tr> <td class="topAlign"><tt>QTextBlockFormat.MinimumHeight</tt></td> <td class="topAlign"><tt>3</tt></td> <td class="topAlign">This sets the minimum line height (in pixels).</td> </tr> <tr> <td class="topAlign"> <tt>QTextBlockFormat.LineDistanceHeight</tt></td> <td class="topAlign"><tt>4</tt></td> <td class="topAlign">This adds the specified height between lines (in pixels).</td> </tr> </table> <p>This enum was introduced or modified in Qt 4.8.</p> <p><b>See also</b> <a href="qtextblockformat.html#lineHeight">lineHeight</a>(), <a href="qtextblockformat.html#lineHeightType">lineHeightType</a>(), and <a href="qtextblockformat.html#setLineHeight">setLineHeight</a>().</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTextBlockFormat" />QTextBlockFormat.__init__ (<i>self</i>)</h3><p>Constructs a new <a href="qtextblockformat.html">QTextBlockFormat</a>.</p> <h3 class="fn"><a name="QTextBlockFormat-2" />QTextBlockFormat.__init__ (<i>self</i>, <a href="qtextblockformat.html">QTextBlockFormat</a>)</h3><h3 class="fn"><a name="alignment" /><a href="qt-alignment.html">Qt.Alignment</a> QTextBlockFormat.alignment (<i>self</i>)</h3><p>Returns the paragraph's alignment.</p> <p><b>See also</b> <a href="qtextblockformat.html#setAlignment">setAlignment</a>().</p> <h3 class="fn"><a name="bottomMargin" />float QTextBlockFormat.bottomMargin (<i>self</i>)</h3><p>Returns the paragraph's bottom margin.</p> <p><b>See also</b> <a href="qtextblockformat.html#setBottomMargin">setBottomMargin</a>() and <a href="qtextblockformat.html#topMargin">topMargin</a>().</p> <h3 class="fn"><a name="indent" />int QTextBlockFormat.indent (<i>self</i>)</h3><p>Returns the paragraph's indent.</p> <p><b>See also</b> <a href="qtextblockformat.html#setIndent">setIndent</a>().</p> <h3 class="fn"><a name="isValid" />bool QTextBlockFormat.isValid (<i>self</i>)</h3><p>Returns true if this block format is valid; otherwise returns false.</p> <h3 class="fn"><a name="leftMargin" />float QTextBlockFormat.leftMargin (<i>self</i>)</h3><p>Returns the paragraph's left margin.</p> <p><b>See also</b> <a href="qtextblockformat.html#setLeftMargin">setLeftMargin</a>(), <a href="qtextblockformat.html#rightMargin">rightMargin</a>(), and <a href="qtextblockformat.html#indent">indent</a>().</p> <h3 class="fn"><a name="lineHeight" />float QTextBlockFormat.lineHeight (<i>self</i>, float <i>scriptLineHeight</i>, float <i>scaling</i>)</h3><p>Returns the height of the lines in the paragraph based on the height of the script line given by <i>scriptLineHeight</i> and the specified <i>scaling</i> factor.</p> <p>The value that is returned is also dependent on the given <a href="qtextformat.html#Property-enum">LineHeightType</a> of the paragraph as well as the <a href="qtextformat.html#Property-enum">LineHeight</a> setting that has been set for the paragraph.</p> <p>The scaling is needed for heights that include a fixed number of pixels, to scale them appropriately for printing.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qtextblockformat.html#LineHeightTypes-enum">LineHeightTypes</a>, <a href="qtextblockformat.html#setLineHeight">setLineHeight</a>(), and <a href="qtextblockformat.html#lineHeightType">lineHeightType</a>().</p> <h3 class="fn"><a name="lineHeight-2" />float QTextBlockFormat.lineHeight (<i>self</i>)</h3><p>This returns the <a href="qtextformat.html#Property-enum">LineHeight</a> property for the paragraph.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qtextblockformat.html#LineHeightTypes-enum">LineHeightTypes</a>, <a href="qtextblockformat.html#setLineHeight">setLineHeight</a>(), and <a href="qtextblockformat.html#lineHeightType">lineHeightType</a>().</p> <h3 class="fn"><a name="lineHeightType" />int QTextBlockFormat.lineHeightType (<i>self</i>)</h3><p>This returns the <a href="qtextformat.html#Property-enum">LineHeightType</a> property of the paragraph.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qtextblockformat.html#LineHeightTypes-enum">LineHeightTypes</a>, <a href="qtextblockformat.html#setLineHeight">setLineHeight</a>(), and <a href="qtextblockformat.html#lineHeight">lineHeight</a>().</p> <h3 class="fn"><a name="nonBreakableLines" />bool QTextBlockFormat.nonBreakableLines (<i>self</i>)</h3><p>Returns true if the lines in the paragraph are non-breakable; otherwise returns false.</p> <p><b>See also</b> <a href="qtextblockformat.html#setNonBreakableLines">setNonBreakableLines</a>().</p> <h3 class="fn"><a name="pageBreakPolicy" /><a href="qtextformat-pagebreakflags.html">QTextFormat.PageBreakFlags</a> QTextBlockFormat.pageBreakPolicy (<i>self</i>)</h3><p>Returns the currently set page break policy for the paragraph. The default is <a href="qtextformat.html#PageBreakFlag-enum">QTextFormat.PageBreak_Auto</a>.</p> <p>This function was introduced in Qt 4.2.</p> <p><b>See also</b> <a href="qtextblockformat.html#setPageBreakPolicy">setPageBreakPolicy</a>().</p> <h3 class="fn"><a name="rightMargin" />float QTextBlockFormat.rightMargin (<i>self</i>)</h3><p>Returns the paragraph's right margin.</p> <p><b>See also</b> <a href="qtextblockformat.html#setRightMargin">setRightMargin</a>() and <a href="qtextblockformat.html#leftMargin">leftMargin</a>().</p> <h3 class="fn"><a name="setAlignment" />QTextBlockFormat.setAlignment (<i>self</i>, <a href="qt-alignment.html">Qt.Alignment</a> <i>aalignment</i>)</h3><p>Sets the paragraph's <i>alignment</i>.</p> <p><b>See also</b> <a href="qtextblockformat.html#alignment">alignment</a>().</p> <h3 class="fn"><a name="setBottomMargin" />QTextBlockFormat.setBottomMargin (<i>self</i>, float <i>margin</i>)</h3><p>Sets the paragraph's bottom <i>margin</i>.</p> <p><b>See also</b> <a href="qtextblockformat.html#bottomMargin">bottomMargin</a>(), <a href="qtextblockformat.html#setTopMargin">setTopMargin</a>(), <a href="qtextblockformat.html#setLeftMargin">setLeftMargin</a>(), and <a href="qtextblockformat.html#setRightMargin">setRightMargin</a>().</p> <h3 class="fn"><a name="setIndent" />QTextBlockFormat.setIndent (<i>self</i>, int <i>aindent</i>)</h3><p>Sets the paragraph's <i>indentation</i>. Margins are set independently of indentation with <a href="qtextblockformat.html#setLeftMargin">setLeftMargin</a>() and <a href="qtextblockformat.html#setTextIndent">setTextIndent</a>(). The <i>indentation</i> is an integer that is multiplied with the document-wide standard indent, resulting in the actual indent of the paragraph.</p> <p><b>See also</b> <a href="qtextblockformat.html#indent">indent</a>() and <a href="qtextdocument.html#indentWidth-prop">QTextDocument.indentWidth</a>().</p> <h3 class="fn"><a name="setLeftMargin" />QTextBlockFormat.setLeftMargin (<i>self</i>, float <i>margin</i>)</h3><p>Sets the paragraph's left <i>margin</i>. Indentation can be applied separately with <a href="qtextblockformat.html#setIndent">setIndent</a>().</p> <p><b>See also</b> <a href="qtextblockformat.html#leftMargin">leftMargin</a>(), <a href="qtextblockformat.html#setRightMargin">setRightMargin</a>(), <a href="qtextblockformat.html#setTopMargin">setTopMargin</a>(), and <a href="qtextblockformat.html#setBottomMargin">setBottomMargin</a>().</p> <h3 class="fn"><a name="setLineHeight" />QTextBlockFormat.setLineHeight (<i>self</i>, float <i>height</i>, int <i>heightType</i>)</h3><p>Sets the line height for the paragraph to the value given by <i>height</i> which is dependent on <i>heightType</i> in the way described by the <a href="qtextblockformat.html#LineHeightTypes-enum">LineHeightTypes</a> enum.</p> <p>This function was introduced in Qt 4.8.</p> <p><b>See also</b> <a href="qtextblockformat.html#LineHeightTypes-enum">LineHeightTypes</a>, <a href="qtextblockformat.html#lineHeight">lineHeight</a>(), and <a href="qtextblockformat.html#lineHeightType">lineHeightType</a>().</p> <h3 class="fn"><a name="setNonBreakableLines" />QTextBlockFormat.setNonBreakableLines (<i>self</i>, bool <i>b</i>)</h3><p>If <i>b</i> is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable.</p> <p><b>See also</b> <a href="qtextblockformat.html#nonBreakableLines">nonBreakableLines</a>().</p> <h3 class="fn"><a name="setPageBreakPolicy" />QTextBlockFormat.setPageBreakPolicy (<i>self</i>, <a href="qtextformat-pagebreakflags.html">QTextFormat.PageBreakFlags</a> <i>flags</i>)</h3><p>Sets the page break policy for the paragraph to <i>policy</i>.</p> <p>This function was introduced in Qt 4.2.</p> <p><b>See also</b> <a href="qtextblockformat.html#pageBreakPolicy">pageBreakPolicy</a>().</p> <h3 class="fn"><a name="setRightMargin" />QTextBlockFormat.setRightMargin (<i>self</i>, float <i>margin</i>)</h3><p>Sets the paragraph's right <i>margin</i>.</p> <p><b>See also</b> <a href="qtextblockformat.html#rightMargin">rightMargin</a>(), <a href="qtextblockformat.html#setLeftMargin">setLeftMargin</a>(), <a href="qtextblockformat.html#setTopMargin">setTopMargin</a>(), and <a href="qtextblockformat.html#setBottomMargin">setBottomMargin</a>().</p> <h3 class="fn"><a name="setTabPositions" />QTextBlockFormat.setTabPositions (<i>self</i>, list-of-QTextOption.Tab <i>tabs</i>)</h3><p>Sets the tab positions for the text block to those specified by <i>tabs</i>.</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also</b> <a href="qtextblockformat.html#tabPositions">tabPositions</a>().</p> <h3 class="fn"><a name="setTextIndent" />QTextBlockFormat.setTextIndent (<i>self</i>, float <i>margin</i>)</h3><p>Sets the <i>indent</i> 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.</p> <p><b>See also</b> <a href="qtextblockformat.html#textIndent">textIndent</a>(), <a href="qtextblockformat.html#setLeftMargin">setLeftMargin</a>(), <a href="qtextblockformat.html#setRightMargin">setRightMargin</a>(), <a href="qtextblockformat.html#setTopMargin">setTopMargin</a>(), and <a href="qtextblockformat.html#setBottomMargin">setBottomMargin</a>().</p> <h3 class="fn"><a name="setTopMargin" />QTextBlockFormat.setTopMargin (<i>self</i>, float <i>margin</i>)</h3><p>Sets the paragraph's top <i>margin</i>.</p> <p><b>See also</b> <a href="qtextblockformat.html#topMargin">topMargin</a>(), <a href="qtextblockformat.html#setBottomMargin">setBottomMargin</a>(), <a href="qtextblockformat.html#setLeftMargin">setLeftMargin</a>(), and <a href="qtextblockformat.html#setRightMargin">setRightMargin</a>().</p> <h3 class="fn"><a name="tabPositions" />list-of-QTextOption.Tab QTextBlockFormat.tabPositions (<i>self</i>)</h3><p>Returns a list of tab positions defined for the text block.</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also</b> <a href="qtextblockformat.html#setTabPositions">setTabPositions</a>().</p> <h3 class="fn"><a name="textIndent" />float QTextBlockFormat.textIndent (<i>self</i>)</h3><p>Returns the paragraph's text indent.</p> <p><b>See also</b> <a href="qtextblockformat.html#setTextIndent">setTextIndent</a>().</p> <h3 class="fn"><a name="topMargin" />float QTextBlockFormat.topMargin (<i>self</i>)</h3><p>Returns the paragraph's top margin.</p> <p><b>See also</b> <a href="qtextblockformat.html#setTopMargin">setTopMargin</a>() and <a href="qtextblockformat.html#bottomMargin">bottomMargin</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>