<?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>QTextStream 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">QTextStream Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QTextStream class provides a convenient interface for reading and writing text. <a href="#details">More...</a></p> <h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qtextstream.html#FieldAlignment-enum">FieldAlignment</a></b> { AlignLeft, AlignRight, AlignCenter, AlignAccountingStyle }</li><li><div class="fn" />enum <b><a href="qtextstream.html#NumberFlag-enum">NumberFlag</a></b> { ShowBase, ForcePoint, ForceSign, UppercaseBase, UppercaseDigits }</li><li><div class="fn" />class <b><a href="qtextstream-numberflags.html">NumberFlags</a></b></li><li><div class="fn" />enum <b><a href="qtextstream.html#RealNumberNotation-enum">RealNumberNotation</a></b> { SmartNotation, FixedNotation, ScientificNotation }</li><li><div class="fn" />enum <b><a href="qtextstream.html#Status-enum">Status</a></b> { Ok, ReadPastEnd, ReadCorruptData, WriteFailed }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtextstream.html#QTextStream">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#QTextStream-2">__init__</a></b> (<i>self</i>, QIODevice <i>device</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#QTextStream-3">__init__</a></b> (<i>self</i>, QString <i>string</i>, QIODevice.OpenMode <i>mode</i> = QIODevice.ReadWrite)</li><li><div class="fn" /><b><a href="qtextstream.html#QTextStream-4">__init__</a></b> (<i>self</i>, QByteArray <i>array</i>, QIODevice.OpenMode <i>mode</i> = QIODevice.ReadWrite)</li><li><div class="fn" />bool <b><a href="qtextstream.html#atEnd">atEnd</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextstream.html#autoDetectUnicode">autoDetectUnicode</a></b> (<i>self</i>)</li><li><div class="fn" />QTextCodec <b><a href="qtextstream.html#codec">codec</a></b> (<i>self</i>)</li><li><div class="fn" />QIODevice <b><a href="qtextstream.html#device">device</a></b> (<i>self</i>)</li><li><div class="fn" />FieldAlignment <b><a href="qtextstream.html#fieldAlignment">fieldAlignment</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextstream.html#fieldWidth">fieldWidth</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#flush">flush</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextstream.html#generateByteOrderMark">generateByteOrderMark</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextstream.html#integerBase">integerBase</a></b> (<i>self</i>)</li><li><div class="fn" />QLocale <b><a href="qtextstream.html#locale">locale</a></b> (<i>self</i>)</li><li><div class="fn" />NumberFlags <b><a href="qtextstream.html#numberFlags">numberFlags</a></b> (<i>self</i>)</li><li><div class="fn" />QChar <b><a href="qtextstream.html#padChar">padChar</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextstream.html#pos">pos</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtextstream.html#read">read</a></b> (<i>self</i>, int <i>maxlen</i>)</li><li><div class="fn" />QString <b><a href="qtextstream.html#readAll">readAll</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtextstream.html#readLine">readLine</a></b> (<i>self</i>, int <i>maxLength</i> = 0)</li><li><div class="fn" />RealNumberNotation <b><a href="qtextstream.html#realNumberNotation">realNumberNotation</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtextstream.html#realNumberPrecision">realNumberPrecision</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#reset">reset</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#resetStatus">resetStatus</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qtextstream.html#seek">seek</a></b> (<i>self</i>, int <i>pos</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setAutoDetectUnicode">setAutoDetectUnicode</a></b> (<i>self</i>, bool <i>enabled</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setCodec">setCodec</a></b> (<i>self</i>, QTextCodec <i>codec</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setCodec-2">setCodec</a></b> (<i>self</i>, str <i>codecName</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setDevice">setDevice</a></b> (<i>self</i>, QIODevice <i>device</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setFieldAlignment">setFieldAlignment</a></b> (<i>self</i>, FieldAlignment <i>alignment</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setFieldWidth">setFieldWidth</a></b> (<i>self</i>, int <i>width</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setGenerateByteOrderMark">setGenerateByteOrderMark</a></b> (<i>self</i>, bool <i>generate</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setIntegerBase">setIntegerBase</a></b> (<i>self</i>, int <i>base</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setLocale">setLocale</a></b> (<i>self</i>, QLocale <i>locale</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setNumberFlags">setNumberFlags</a></b> (<i>self</i>, NumberFlags <i>flags</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setPadChar">setPadChar</a></b> (<i>self</i>, QChar <i>ch</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setRealNumberNotation">setRealNumberNotation</a></b> (<i>self</i>, RealNumberNotation <i>notation</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setRealNumberPrecision">setRealNumberPrecision</a></b> (<i>self</i>, int <i>precision</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setStatus">setStatus</a></b> (<i>self</i>, Status <i>status</i>)</li><li><div class="fn" /><b><a href="qtextstream.html#setString">setString</a></b> (<i>self</i>, QString <i>string</i>, QIODevice.OpenMode <i>mode</i> = QIODevice.ReadWrite)</li><li><div class="fn" /><b><a href="qtextstream.html#skipWhiteSpace">skipWhiteSpace</a></b> (<i>self</i>)</li><li><div class="fn" />Status <b><a href="qtextstream.html#status">status</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtextstream.html#string">string</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />QTextStream <b><a href="qtxml.html#__lshift__">__lshift__</a></b> (<i>self</i>, QDomNode)</li><li><div class="fn" />QTextStream <b><a href="qtgui.html#__lshift__-21">__lshift__</a></b> (<i>self</i>, QSplitter)</li><li><div class="fn" />QTextStream <b><a href="qtgui.html#__rshift__-21">__rshift__</a></b> (<i>self</i>, QSplitter)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__lshift__">__lshift__</a></b> (<i>self</i>, float <i>f</i>)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__lshift__-2">__lshift__</a></b> (<i>self</i>, bool <i>b</i>)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__lshift__-3">__lshift__</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__lshift__-4">__lshift__</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__lshift__-5">__lshift__</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__lshift__-6">__lshift__</a></b> (<i>self</i>, QString <i>s</i>)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__lshift__-7">__lshift__</a></b> (<i>self</i>, QByteArray <i>array</i>)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__lshift__-8">__lshift__</a></b> (<i>self</i>, QTextStreamManipulator <i>m</i>)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__rshift__">__rshift__</a></b> (<i>self</i>, QChar <i>ch</i>)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__rshift__-2">__rshift__</a></b> (<i>self</i>, QString <i>s</i>)</li><li><div class="fn" />QTextStream <b><a href="qtextstream.html#__rshift__-3">__rshift__</a></b> (<i>self</i>, QByteArray <i>array</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTextStream class provides a convenient interface for reading and writing text.</p> <p>QTextStream can operate on a <a href="qiodevice.html">QIODevice</a>, a <a href="qbytearray.html">QByteArray</a> or a <a href="qstring.html">QString</a>. Using QTextStream's streaming operators, you can conveniently read and write words, lines and numbers. For generating text, QTextStream supports formatting options for field padding and alignment, and formatting of numbers. Example:</p> <pre class="cpp"> <span class="type"><a href="qfile.html">QFile</a></span> data(<span class="string">"output.txt"</span>); <span class="keyword">if</span> (data<span class="operator">.</span>open(<span class="type"><a href="qfile.html">QFile</a></span><span class="operator">.</span>WriteOnly <span class="operator">|</span> <span class="type"><a href="qfile.html">QFile</a></span><span class="operator">.</span>Truncate)) { <span class="type">QTextStream</span> out(<span class="operator">&</span>data); out <span class="operator"><</span><span class="operator"><</span> <span class="string">"Result: "</span> <span class="operator"><</span><span class="operator"><</span> <a href="qtcore.html#qSetFieldWidth">qSetFieldWidth</a>(<span class="number">10</span>) <span class="operator"><</span><span class="operator"><</span> left <span class="operator"><</span><span class="operator"><</span> <span class="number">3.14</span> <span class="operator"><</span><span class="operator"><</span> <span class="number">2.7</span>; <span class="comment">// writes "Result: 3.14 2.7 "</span> } </pre> <p>It's also common to use QTextStream to read console input and write console output. QTextStream is locale aware, and will automatically decode standard input using the correct codec. Example:</p> <pre class="cpp"> <span class="type">QTextStream</span> stream(stdin); <span class="type"><a href="qstring.html">QString</a></span> line; <span class="keyword">do</span> { line <span class="operator">=</span> stream<span class="operator">.</span>readLine(); } <span class="keyword">while</span> (<span class="operator">!</span>line<span class="operator">.</span>isNull()); </pre> <p>Besides using QTextStream's constructors, you can also set the device or string QTextStream operates on by calling <a href="qtextstream.html#setDevice">setDevice</a>() or <a href="qtextstream.html#setString">setString</a>(). You can seek to a position by calling <a href="qtextstream.html#seek">seek</a>(), and <a href="qtextstream.html#atEnd">atEnd</a>() will return true when there is no data left to be read. If you call <a href="qtcore.html#flush">flush</a>(), QTextStream will empty all data from its write buffer into the device and call <a href="qtcore.html#flush">flush</a>() on the device.</p> <p>Internally, QTextStream uses a Unicode based buffer, and <a href="qtextcodec.html">QTextCodec</a> is used by QTextStream to automatically support different character sets. By default, <a href="qtextcodec.html#codecForLocale">QTextCodec.codecForLocale</a>() is used for reading and writing, but you can also set the codec by calling <a href="qtextstream.html#setCodec">setCodec</a>(). Automatic Unicode detection is also supported. When this feature is enabled (the default behavior), QTextStream will detect the UTF-16 or the UTF-32 BOM (Byte Order Mark) and switch to the appropriate UTF codec when reading. QTextStream does not write a BOM by default, but you can enable this by calling setGenerateByteOrderMark(true). When QTextStream operates on a <a href="qstring.html">QString</a> directly, the codec is disabled.</p> <p>There are three general ways to use QTextStream when reading text files:</p> <ul> <li>Chunk by chunk, by calling <a href="qtextstream.html#readLine">readLine</a>() or <a href="qtextstream.html#readAll">readAll</a>().</li> <li>Word by word. QTextStream supports streaming into QStrings, QByteArrays and char* buffers. Words are delimited by space, and leading white space is automatically skipped.</li> <li>Character by character, by streaming into <a href="qchar.html">QChar</a> or char types. This method is often used for convenient input handling when parsing files, independent of character encoding and end-of-line semantics. To skip white space, call <a href="qtextstream.html#skipWhiteSpace">skipWhiteSpace</a>().</li> </ul> <p>Since the text stream uses a buffer, you should not read from the stream using the implementation of a superclass. For instance, if you have a <a href="qfile.html">QFile</a> and read from it directly using <a href="qiodevice.html#readLine">QFile.readLine</a>() instead of using the stream, the text stream's internal position will be out of sync with the file's position.</p> <p>By default, when reading numbers from a stream of text, QTextStream will automatically detect the number's base representation. For example, if the number starts with "0x", it is assumed to be in hexadecimal form. If it starts with the digits 1-9, it is assumed to be in decimal form, and so on. You can set the integer base, thereby disabling the automatic detection, by calling <a href="qtextstream.html#setIntegerBase">setIntegerBase</a>(). Example:</p> <pre class="cpp"> <span class="type">QTextStream</span> in(<span class="string">"0x50 0x20"</span>); <span class="type">int</span> firstNumber<span class="operator">,</span> secondNumber; in <span class="operator">></span><span class="operator">></span> firstNumber; <span class="comment">// firstNumber == 80</span> in <span class="operator">></span><span class="operator">></span> dec <span class="operator">></span><span class="operator">></span> secondNumber; <span class="comment">// secondNumber == 0</span> <span class="type">char</span> ch; in <span class="operator">></span><span class="operator">></span> ch; <span class="comment">// ch == 'x'</span> </pre> <p>QTextStream supports many formatting options for generating text. You can set the field width and pad character by calling <a href="qtextstream.html#setFieldWidth">setFieldWidth</a>() and <a href="qtextstream.html#setPadChar">setPadChar</a>(). Use <a href="qtextstream.html#setFieldAlignment">setFieldAlignment</a>() to set the alignment within each field. For real numbers, call <a href="qtextstream.html#setRealNumberNotation">setRealNumberNotation</a>() and <a href="qtextstream.html#setRealNumberPrecision">setRealNumberPrecision</a>() to set the notation (<a href="qtextstream.html#RealNumberNotation-enum">SmartNotation</a>, <a href="qtextstream.html#RealNumberNotation-enum">ScientificNotation</a>, <a href="qtextstream.html#RealNumberNotation-enum">FixedNotation</a>) and precision in digits of the generated number. Some extra number formatting options are also available through <a href="qtextstream.html#setNumberFlags">setNumberFlags</a>().</p> <a id="qtextstream-manipulators" name="qtextstream-manipulators" /> <p>Like <tt><iostream></tt> in the standard C++ library, QTextStream also defines several global manipulator functions:</p> <table class="generic"> <thead> <tr class="qt-style"> <th>Manipulator</th> <th>Description</th> </tr> </thead> <tr class="odd" valign="top"> <td><tt>bin</tt></td> <td>Same as setIntegerBase(2).</td> </tr> <tr class="even" valign="top"> <td><tt>oct</tt></td> <td>Same as setIntegerBase(8).</td> </tr> <tr class="odd" valign="top"> <td><tt>dec</tt></td> <td>Same as setIntegerBase(10).</td> </tr> <tr class="even" valign="top"> <td><tt>hex</tt></td> <td>Same as setIntegerBase(16).</td> </tr> <tr class="odd" valign="top"> <td><tt>showbase</tt></td> <td>Same as setNumberFlags(<a href="qtextstream.html#numberFlags">numberFlags</a>() | <a href="qtextstream.html#NumberFlag-enum">ShowBase</a>).</td> </tr> <tr class="even" valign="top"> <td><tt>forcesign</tt></td> <td>Same as setNumberFlags(<a href="qtextstream.html#numberFlags">numberFlags</a>() | <a href="qtextstream.html#NumberFlag-enum">ForceSign</a>).</td> </tr> <tr class="odd" valign="top"> <td><tt>forcepoint</tt></td> <td>Same as setNumberFlags(<a href="qtextstream.html#numberFlags">numberFlags</a>() | <a href="qtextstream.html#NumberFlag-enum">ForcePoint</a>).</td> </tr> <tr class="even" valign="top"> <td><tt>noshowbase</tt></td> <td>Same as setNumberFlags(<a href="qtextstream.html#numberFlags">numberFlags</a>() & ~<a href="qtextstream.html#NumberFlag-enum">ShowBase</a>).</td> </tr> <tr class="odd" valign="top"> <td><tt>noforcesign</tt></td> <td>Same as setNumberFlags(<a href="qtextstream.html#numberFlags">numberFlags</a>() & ~<a href="qtextstream.html#NumberFlag-enum">ForceSign</a>).</td> </tr> <tr class="even" valign="top"> <td><tt>noforcepoint</tt></td> <td>Same as setNumberFlags(<a href="qtextstream.html#numberFlags">numberFlags</a>() & ~<a href="qtextstream.html#NumberFlag-enum">ForcePoint</a>).</td> </tr> <tr class="odd" valign="top"> <td><tt>uppercasebase</tt></td> <td>Same as setNumberFlags(<a href="qtextstream.html#numberFlags">numberFlags</a>() | <a href="qtextstream.html#NumberFlag-enum">UppercaseBase</a>).</td> </tr> <tr class="even" valign="top"> <td><tt>uppercasedigits</tt></td> <td>Same as setNumberFlags(<a href="qtextstream.html#numberFlags">numberFlags</a>() | <a href="qtextstream.html#NumberFlag-enum">UppercaseDigits</a>).</td> </tr> <tr class="odd" valign="top"> <td><tt>lowercasebase</tt></td> <td>Same as setNumberFlags(<a href="qtextstream.html#numberFlags">numberFlags</a>() & ~<a href="qtextstream.html#NumberFlag-enum">UppercaseBase</a>).</td> </tr> <tr class="even" valign="top"> <td><tt>lowercasedigits</tt></td> <td>Same as setNumberFlags(<a href="qtextstream.html#numberFlags">numberFlags</a>() & ~<a href="qtextstream.html#NumberFlag-enum">UppercaseDigits</a>).</td> </tr> <tr class="odd" valign="top"> <td><tt>fixed</tt></td> <td>Same as setRealNumberNotation(<a href="qtextstream.html#RealNumberNotation-enum">FixedNotation</a>).</td> </tr> <tr class="even" valign="top"> <td><tt>scientific</tt></td> <td>Same as setRealNumberNotation(<a href="qtextstream.html#RealNumberNotation-enum">ScientificNotation</a>).</td> </tr> <tr class="odd" valign="top"> <td><tt>left</tt></td> <td>Same as setFieldAlignment(<a href="qtextstream.html#FieldAlignment-enum">AlignLeft</a>).</td> </tr> <tr class="even" valign="top"> <td><tt>right</tt></td> <td>Same as setFieldAlignment(<a href="qtextstream.html#FieldAlignment-enum">AlignRight</a>).</td> </tr> <tr class="odd" valign="top"> <td><tt>center</tt></td> <td>Same as setFieldAlignment(<a href="qtextstream.html#FieldAlignment-enum">AlignCenter</a>).</td> </tr> <tr class="even" valign="top"> <td><tt>endl</tt></td> <td>Same as operator<<('\n') and <a href="qtcore.html#flush">flush</a>().</td> </tr> <tr class="odd" valign="top"> <td><tt>flush</tt></td> <td>Same as <a href="qtcore.html#flush">flush</a>().</td> </tr> <tr class="even" valign="top"> <td><tt>reset</tt></td> <td>Same as <a href="qtcore.html#reset">reset</a>().</td> </tr> <tr class="odd" valign="top"> <td><tt>ws</tt></td> <td>Same as <a href="qtextstream.html#skipWhiteSpace">skipWhiteSpace</a>().</td> </tr> <tr class="even" valign="top"> <td><tt>bom</tt></td> <td>Same as setGenerateByteOrderMark(true).</td> </tr> </table> <p>In addition, Qt provides three global manipulators that take a parameter: <a href="qtcore.html#qSetFieldWidth">qSetFieldWidth</a>(), <a href="qtcore.html#qSetPadChar">qSetPadChar</a>(), and <a href="qtcore.html#qSetRealNumberPrecision">qSetRealNumberPrecision</a>().</p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="FieldAlignment-enum" />QTextStream.FieldAlignment</h3><p>This enum specifies how to align text in fields when the field is wider than the text that occupies it.</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>QTextStream.AlignLeft</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">Pad on the right side of fields.</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.AlignRight</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">Pad on the left side of fields.</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.AlignCenter</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">Pad on both sides of field.</td> </tr> <tr> <td class="topAlign"> <tt>QTextStream.AlignAccountingStyle</tt></td> <td class="topAlign"><tt>3</tt></td> <td class="topAlign">Same as AlignRight, except that the sign of a number is flush left.</td> </tr> </table> <p><b>See also</b> <a href="qtextstream.html#setFieldAlignment">setFieldAlignment</a>().</p> <h3 class="fn"><a name="NumberFlag-enum" />QTextStream.NumberFlag</h3><p>This enum specifies various flags that can be set to affect the output of integers, <tt>float</tt>s, and <tt>double</tt>s.</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>QTextStream.ShowBase</tt></td> <td class="topAlign"><tt>0x1</tt></td> <td class="topAlign">Show the base as a prefix if the base is 16 ("0x"), 8 ("0"), or 2 ("0b").</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.ForcePoint</tt></td> <td class="topAlign"><tt>0x2</tt></td> <td class="topAlign">Always put the decimal separator in numbers, even if there are no decimals.</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.ForceSign</tt></td> <td class="topAlign"><tt>0x4</tt></td> <td class="topAlign">Always put the sign in numbers, even for positive numbers.</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.UppercaseBase</tt></td> <td class="topAlign"><tt>0x8</tt></td> <td class="topAlign">Use uppercase versions of base prefixes ("0X", "0B").</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.UppercaseDigits</tt></td> <td class="topAlign"><tt>0x10</tt></td> <td class="topAlign">Use uppercase letters for expressing digits 10 to 35 instead of lowercase.</td> </tr> </table> <p>The NumberFlags type is a typedef for <a href="qflags.html">QFlags</a><NumberFlag>. It stores an OR combination of NumberFlag values.</p> <p><b>See also</b> <a href="qtextstream.html#setNumberFlags">setNumberFlags</a>().</p> <h3 class="fn"><a name="RealNumberNotation-enum" />QTextStream.RealNumberNotation</h3><p>This enum specifies which notations to use for expressing <tt>float</tt> and <tt>double</tt> as strings.</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>QTextStream.ScientificNotation</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">Scientific notation (<tt>printf()</tt>'s <tt>%e</tt> flag).</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.FixedNotation</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">Fixed-point notation (<tt>printf()</tt>'s <tt>%f</tt> flag).</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.SmartNotation</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">Scientific or fixed-point notation, depending on which makes most sense (<tt>printf()</tt>'s <tt>%g</tt> flag).</td> </tr> </table> <p><b>See also</b> <a href="qtextstream.html#setRealNumberNotation">setRealNumberNotation</a>().</p> <h3 class="fn"><a name="Status-enum" />QTextStream.Status</h3><p>This enum describes the current status of the text stream.</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>QTextStream.Ok</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">The text stream is operating normally.</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.ReadPastEnd</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">The text stream has read past the end of the data in the underlying device.</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.ReadCorruptData</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">The text stream has read corrupt data.</td> </tr> <tr> <td class="topAlign"><tt>QTextStream.WriteFailed</tt></td> <td class="topAlign"><tt>3</tt></td> <td class="topAlign">The text stream cannot write to the underlying device.</td> </tr> </table> <p><b>See also</b> <a href="qtextstream.html#status">status</a>().</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTextStream" />QTextStream.__init__ (<i>self</i>)</h3><p>Constructs a <a href="qtextstream.html">QTextStream</a>. Before you can use it for reading or writing, you must assign a device or a string.</p> <p><b>See also</b> <a href="qtextstream.html#setDevice">setDevice</a>() and <a href="qtextstream.html#setString">setString</a>().</p> <h3 class="fn"><a name="QTextStream-2" />QTextStream.__init__ (<i>self</i>, <a href="qiodevice.html">QIODevice</a> <i>device</i>)</h3><p>Constructs a <a href="qtextstream.html">QTextStream</a> that operates on <i>device</i>.</p> <h3 class="fn"><a name="QTextStream-3" />QTextStream.__init__ (<i>self</i>, QString <i>string</i>, <a href="qiodevice-openmode.html">QIODevice.OpenMode</a> <i>mode</i> = QIODevice.ReadWrite)</h3><p>Constructs a <a href="qtextstream.html">QTextStream</a> that operates on <i>fileHandle</i>, using <i>openMode</i> to define the open mode. Internally, a <a href="qfile.html">QFile</a> is created to handle the FILE pointer.</p> <p>This constructor is useful for working directly with the common FILE based input and output streams: stdin, stdout and stderr. Example:</p> <pre class="cpp"> <span class="type"><a href="qstring.html">QString</a></span> str; <span class="type"><a href="qtextstream.html">QTextStream</a></span> in(stdin); in <span class="operator">></span><span class="operator">></span> str; </pre> <h3 class="fn"><a name="QTextStream-4" />QTextStream.__init__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>array</i>, <a href="qiodevice-openmode.html">QIODevice.OpenMode</a> <i>mode</i> = QIODevice.ReadWrite)</h3><p>Constructs a <a href="qtextstream.html">QTextStream</a> that operates on <i>string</i>, using <i>openMode</i> to define the open mode.</p> <h3 class="fn"><a name="atEnd" />bool QTextStream.atEnd (<i>self</i>)</h3><p>Returns true if there is no more data to be read from the <a href="qtextstream.html">QTextStream</a>; otherwise returns false. This is similar to, but not the same as calling <a href="qiodevice.html#atEnd">QIODevice.atEnd</a>(), as <a href="qtextstream.html">QTextStream</a> also takes into account its internal Unicode buffer.</p> <h3 class="fn"><a name="autoDetectUnicode" />bool QTextStream.autoDetectUnicode (<i>self</i>)</h3><p>Returns true if automatic Unicode detection is enabled, otherwise returns false. Automatic Unicode detection is enabled by default.</p> <p><b>See also</b> <a href="qtextstream.html#setAutoDetectUnicode">setAutoDetectUnicode</a>() and <a href="qtextstream.html#setCodec">setCodec</a>().</p> <h3 class="fn"><a name="codec" /><a href="qtextcodec.html">QTextCodec</a> QTextStream.codec (<i>self</i>)</h3><p>Returns the codec that is current assigned to the stream.</p> <p><b>See also</b> <a href="qtextstream.html#setCodec">setCodec</a>(), <a href="qtextstream.html#setAutoDetectUnicode">setAutoDetectUnicode</a>(), and <a href="qtextstream.html#locale">locale</a>().</p> <h3 class="fn"><a name="device" /><a href="qiodevice.html">QIODevice</a> QTextStream.device (<i>self</i>)</h3><p>Returns the current device associated with the <a href="qtextstream.html">QTextStream</a>, or 0 if no device has been assigned.</p> <p><b>See also</b> <a href="qtextstream.html#setDevice">setDevice</a>() and <a href="qtextstream.html#string">string</a>().</p> <h3 class="fn"><a name="fieldAlignment" /><a href="qtextstream.html#FieldAlignment-enum">FieldAlignment</a> QTextStream.fieldAlignment (<i>self</i>)</h3><p>Returns the current field alignment.</p> <p><b>See also</b> <a href="qtextstream.html#setFieldAlignment">setFieldAlignment</a>() and <a href="qtextstream.html#fieldWidth">fieldWidth</a>().</p> <h3 class="fn"><a name="fieldWidth" />int QTextStream.fieldWidth (<i>self</i>)</h3><p>Returns the current field width.</p> <p><b>See also</b> <a href="qtextstream.html#setFieldWidth">setFieldWidth</a>().</p> <h3 class="fn"><a name="flush" />QTextStream.flush (<i>self</i>)</h3><p>Flushes any buffered data waiting to be written to the device.</p> <p>If <a href="qtextstream.html">QTextStream</a> operates on a string, this function does nothing.</p> <h3 class="fn"><a name="generateByteOrderMark" />bool QTextStream.generateByteOrderMark (<i>self</i>)</h3><p>Returns true if <a href="qtextstream.html">QTextStream</a> is set to generate the UTF BOM (Byte Order Mark) when using a UTF codec; otherwise returns false. UTF BOM generation is set to false by default.</p> <p><b>See also</b> <a href="qtextstream.html#setGenerateByteOrderMark">setGenerateByteOrderMark</a>().</p> <h3 class="fn"><a name="integerBase" />int QTextStream.integerBase (<i>self</i>)</h3><p>Returns the current base of integers. 0 means that the base is detected when reading, or 10 (decimal) when generating numbers.</p> <p><b>See also</b> <a href="qtextstream.html#setIntegerBase">setIntegerBase</a>(), <a href="qstring.html#number">QString.number</a>(), and <a href="qtextstream.html#numberFlags">numberFlags</a>().</p> <h3 class="fn"><a name="locale" /><a href="qlocale.html">QLocale</a> QTextStream.locale (<i>self</i>)</h3><p>Returns the locale for this stream. The default locale is C.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qtextstream.html#setLocale">setLocale</a>().</p> <h3 class="fn"><a name="numberFlags" /><a href="qtextstream-numberflags.html">NumberFlags</a> QTextStream.numberFlags (<i>self</i>)</h3><p>Returns the current number flags.</p> <p><b>See also</b> <a href="qtextstream.html#setNumberFlags">setNumberFlags</a>(), <a href="qtextstream.html#integerBase">integerBase</a>(), and <a href="qtextstream.html#realNumberNotation">realNumberNotation</a>().</p> <h3 class="fn"><a name="padChar" />QChar QTextStream.padChar (<i>self</i>)</h3><p>Returns the current pad character.</p> <p><b>See also</b> <a href="qtextstream.html#setPadChar">setPadChar</a>() and <a href="qtextstream.html#setFieldWidth">setFieldWidth</a>().</p> <h3 class="fn"><a name="pos" />int QTextStream.pos (<i>self</i>)</h3><p>Returns the device position corresponding to the current position of the stream, or -1 if an error occurs (e.g., if there is no device or string, or if there's a device error).</p> <p>Because <a href="qtextstream.html">QTextStream</a> is buffered, this function may have to seek the device to reconstruct a valid device position. This operation can be expensive, so you may want to avoid calling this function in a tight loop.</p> <p>This function was introduced in Qt 4.2.</p> <p><b>See also</b> <a href="qtextstream.html#seek">seek</a>().</p> <h3 class="fn"><a name="read" />QString QTextStream.read (<i>self</i>, int <i>maxlen</i>)</h3><p>Reads at most <i>maxlen</i> characters from the stream, and returns the data read as a <a href="qstring.html">QString</a>.</p> <p>This function was introduced in Qt 4.1.</p> <p><b>See also</b> <a href="qtextstream.html#readAll">readAll</a>(), <a href="qtextstream.html#readLine">readLine</a>(), and <a href="qiodevice.html#read">QIODevice.read</a>().</p> <h3 class="fn"><a name="readAll" />QString QTextStream.readAll (<i>self</i>)</h3><p>Reads the entire content of the stream, and returns it as a <a href="qstring.html">QString</a>. Avoid this function when working on large files, as it will consume a significant amount of memory.</p> <p>Calling <a href="qtextstream.html#readLine">readLine</a>() is better if you do not know how much data is available.</p> <p><b>See also</b> <a href="qtextstream.html#readLine">readLine</a>().</p> <h3 class="fn"><a name="readLine" />QString QTextStream.readLine (<i>self</i>, int <i>maxLength</i> = 0)</h3><p>Reads one line of text from the stream, and returns it as a <a href="qstring.html">QString</a>. The maximum allowed line length is set to <i>maxlen</i>. If the stream contains lines longer than this, then the lines will be split after <i>maxlen</i> characters and returned in parts.</p> <p>If <i>maxlen</i> is 0, the lines can be of any length. A common value for <i>maxlen</i> is 75.</p> <p>The returned line has no trailing end-of-line characters ("\n" or "\r\n"), so calling <a href="qstring.html#trimmed">QString.trimmed</a>() is unnecessary.</p> <p>If the stream has read to the end of the file, readLine() will return a null <a href="qstring.html">QString</a>. For strings, or for devices that support it, you can explicitly test for the end of the stream using <a href="qtextstream.html#atEnd">atEnd</a>().</p> <p><b>See also</b> <a href="qtextstream.html#readAll">readAll</a>() and <a href="qiodevice.html#readLine">QIODevice.readLine</a>().</p> <h3 class="fn"><a name="realNumberNotation" /><a href="qtextstream.html#RealNumberNotation-enum">RealNumberNotation</a> QTextStream.realNumberNotation (<i>self</i>)</h3><p>Returns the current real number notation.</p> <p><b>See also</b> <a href="qtextstream.html#setRealNumberNotation">setRealNumberNotation</a>(), <a href="qtextstream.html#realNumberPrecision">realNumberPrecision</a>(), <a href="qtextstream.html#numberFlags">numberFlags</a>(), and <a href="qtextstream.html#integerBase">integerBase</a>().</p> <h3 class="fn"><a name="realNumberPrecision" />int QTextStream.realNumberPrecision (<i>self</i>)</h3><p>Returns the current real number precision, or the number of fraction digits <a href="qtextstream.html">QTextStream</a> will write when generating real numbers.</p> <p><b>See also</b> <a href="qtextstream.html#setRealNumberPrecision">setRealNumberPrecision</a>(), <a href="qtextstream.html#setRealNumberNotation">setRealNumberNotation</a>(), <a href="qtextstream.html#realNumberNotation">realNumberNotation</a>(), <a href="qtextstream.html#numberFlags">numberFlags</a>(), and <a href="qtextstream.html#integerBase">integerBase</a>().</p> <h3 class="fn"><a name="reset" />QTextStream.reset (<i>self</i>)</h3><p>Resets <a href="qtextstream.html">QTextStream</a>'s formatting options, bringing it back to its original constructed state. The device, string and any buffered data is left untouched.</p> <h3 class="fn"><a name="resetStatus" />QTextStream.resetStatus (<i>self</i>)</h3><p>Resets the status of the text stream.</p> <p>This function was introduced in Qt 4.1.</p> <p><b>See also</b> <a href="qtextstream.html#Status-enum">QTextStream.Status</a>, <a href="qtextstream.html#status">status</a>(), and <a href="qtextstream.html#setStatus">setStatus</a>().</p> <h3 class="fn"><a name="seek" />bool QTextStream.seek (<i>self</i>, int <i>pos</i>)</h3><p>Seeks to the position <i>pos</i> in the device. Returns true on success; otherwise returns false.</p> <h3 class="fn"><a name="setAutoDetectUnicode" />QTextStream.setAutoDetectUnicode (<i>self</i>, bool <i>enabled</i>)</h3><p>If <i>enabled</i> is true, <a href="qtextstream.html">QTextStream</a> will attempt to detect Unicode encoding by peeking into the stream data to see if it can find the UTF-16 or UTF-32 BOM (Byte Order Mark). If this mark is found, <a href="qtextstream.html">QTextStream</a> will replace the current codec with the UTF codec.</p> <p>This function can be used together with <a href="qtextstream.html#setCodec">setCodec</a>(). It is common to set the codec to UTF-8, and then enable UTF-16 detection.</p> <p><b>See also</b> <a href="qtextstream.html#autoDetectUnicode">autoDetectUnicode</a>() and <a href="qtextstream.html#setCodec">setCodec</a>().</p> <h3 class="fn"><a name="setCodec" />QTextStream.setCodec (<i>self</i>, <a href="qtextcodec.html">QTextCodec</a> <i>codec</i>)</h3><p>Sets the codec for this stream to <i>codec</i>. The codec is used for decoding any data that is read from the assigned device, and for encoding any data that is written. By default, <a href="qtextcodec.html#codecForLocale">QTextCodec.codecForLocale</a>() is used, and automatic unicode detection is enabled.</p> <p>If <a href="qtextstream.html">QTextStream</a> operates on a string, this function does nothing.</p> <p><b>Warning:</b> If you call this function while the text stream is reading from an open sequential socket, the internal buffer may still contain text decoded using the old codec.</p> <p><b>See also</b> <a href="qtextstream.html#codec">codec</a>(), <a href="qtextstream.html#setAutoDetectUnicode">setAutoDetectUnicode</a>(), and <a href="qtextstream.html#setLocale">setLocale</a>().</p> <h3 class="fn"><a name="setCodec-2" />QTextStream.setCodec (<i>self</i>, str <i>codecName</i>)</h3><p>Sets the codec for this stream to the <a href="qtextcodec.html">QTextCodec</a> for the encoding specified by <i>codecName</i>. Common values for <tt>codecName</tt> include "ISO 8859-1", "UTF-8", and "UTF-16". If the encoding isn't recognized, nothing happens.</p> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qtextstream.html">QTextStream</a></span> out(<span class="operator">&</span>file); out<span class="operator">.</span><a href="qtextstream.html#setCodec">setCodec</a>(<span class="string">"UTF-8"</span>); </pre> <p><b>See also</b> <a href="qtextcodec.html#codecForName">QTextCodec.codecForName</a>() and <a href="qtextstream.html#setLocale">setLocale</a>().</p> <h3 class="fn"><a name="setDevice" />QTextStream.setDevice (<i>self</i>, <a href="qiodevice.html">QIODevice</a> <i>device</i>)</h3><p>Sets the current device to <i>device</i>. If a device has already been assigned, <a href="qtextstream.html">QTextStream</a> will call <a href="qtcore.html#flush">flush</a>() before the old device is replaced.</p> <p><b>Note:</b> This function resets locale to the default locale ('C') and codec to the default codec, <a href="qtextcodec.html#codecForLocale">QTextCodec.codecForLocale</a>().</p> <p><b>See also</b> <a href="qtextstream.html#device">device</a>() and <a href="qtextstream.html#setString">setString</a>().</p> <h3 class="fn"><a name="setFieldAlignment" />QTextStream.setFieldAlignment (<i>self</i>, <a href="qtextstream.html#FieldAlignment-enum">FieldAlignment</a> <i>alignment</i>)</h3><p>Sets the field alignment to <i>mode</i>. When used together with <a href="qtextstream.html#setFieldWidth">setFieldWidth</a>(), this function allows you to generate formatted output with text aligned to the left, to the right or center aligned.</p> <p><b>See also</b> <a href="qtextstream.html#fieldAlignment">fieldAlignment</a>() and <a href="qtextstream.html#setFieldWidth">setFieldWidth</a>().</p> <h3 class="fn"><a name="setFieldWidth" />QTextStream.setFieldWidth (<i>self</i>, int <i>width</i>)</h3><p>Sets the current field width to <i>width</i>. If <i>width</i> is 0 (the default), the field width is equal to the length of the generated text.</p> <p><b>Note:</b> The field width applies to every element appended to this stream after this function has been called (e.g., it also pads endl). This behavior is different from similar classes in the STL, where the field width only applies to the next element.</p> <p><b>See also</b> <a href="qtextstream.html#fieldWidth">fieldWidth</a>() and <a href="qtextstream.html#setPadChar">setPadChar</a>().</p> <h3 class="fn"><a name="setGenerateByteOrderMark" />QTextStream.setGenerateByteOrderMark (<i>self</i>, bool <i>generate</i>)</h3><p>If <i>generate</i> is true and a UTF codec is used, <a href="qtextstream.html">QTextStream</a> will insert the BOM (Byte Order Mark) before any data has been written to the device. If <i>generate</i> is false, no BOM will be inserted. This function must be called before any data is written. Otherwise, it does nothing.</p> <p><b>See also</b> <a href="qtextstream.html#generateByteOrderMark">generateByteOrderMark</a>() and <a href="qtcore.html#bom">bom</a>().</p> <h3 class="fn"><a name="setIntegerBase" />QTextStream.setIntegerBase (<i>self</i>, int <i>base</i>)</h3><p>Sets the base of integers to <i>base</i>, both for reading and for generating numbers. <i>base</i> can be either 2 (binary), 8 (octal), 10 (decimal) or 16 (hexadecimal). If <i>base</i> is 0, <a href="qtextstream.html">QTextStream</a> will attempt to detect the base by inspecting the data on the stream. When generating numbers, <a href="qtextstream.html">QTextStream</a> assumes base is 10 unless the base has been set explicitly.</p> <p><b>See also</b> <a href="qtextstream.html#integerBase">integerBase</a>(), <a href="qstring.html#number">QString.number</a>(), and <a href="qtextstream.html#setNumberFlags">setNumberFlags</a>().</p> <h3 class="fn"><a name="setLocale" />QTextStream.setLocale (<i>self</i>, <a href="qlocale.html">QLocale</a> <i>locale</i>)</h3><p>Sets the locale for this stream to <i>locale</i>. The specified locale is used for conversions between numbers and their string representations.</p> <p>The default locale is C and it is a special case - the thousands group separator is not used for backward compatibility reasons.</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qtextstream.html#locale">locale</a>().</p> <h3 class="fn"><a name="setNumberFlags" />QTextStream.setNumberFlags (<i>self</i>, <a href="qtextstream-numberflags.html">NumberFlags</a> <i>flags</i>)</h3><p>Sets the current number flags to <i>flags</i>. <i>flags</i> is a set of flags from the <a href="qtextstream.html#NumberFlag-enum">NumberFlag</a> enum, and describes options for formatting generated code (e.g., whether or not to always write the base or sign of a number).</p> <p><b>See also</b> <a href="qtextstream.html#numberFlags">numberFlags</a>(), <a href="qtextstream.html#setIntegerBase">setIntegerBase</a>(), and <a href="qtextstream.html#setRealNumberNotation">setRealNumberNotation</a>().</p> <h3 class="fn"><a name="setPadChar" />QTextStream.setPadChar (<i>self</i>, QChar <i>ch</i>)</h3><p>Sets the pad character to <i>ch</i>. The default value is the ASCII space character (' '), or <a href="qchar.html">QChar</a>(0x20). This character is used to fill in the space in fields when generating text.</p> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qstring.html">QString</a></span> s; <span class="type"><a href="qtextstream.html">QTextStream</a></span> out(<span class="operator">&</span>s); out<span class="operator">.</span><a href="qtextstream.html#setFieldWidth">setFieldWidth</a>(<span class="number">10</span>); out<span class="operator">.</span><a href="qtextstream.html#setFieldAlignment">setFieldAlignment</a>(<span class="type"><a href="qtextstream.html">QTextStream</a></span><span class="operator">.</span>AlignCenter); out<span class="operator">.</span>setPadChar(<span class="char">'-'</span>); out <span class="operator"><</span><span class="operator"><</span> <span class="string">"Qt"</span> <span class="operator"><</span><span class="operator"><</span> <span class="string">"rocks!"</span>; </pre> <p>The string <tt>s</tt> contains:</p> <pre class="cpp"> <span class="operator">-</span><span class="operator">-</span><span class="operator">-</span><span class="operator">-</span><span class="type"><a href="qt.html">Qt</a></span><span class="operator">-</span><span class="operator">-</span><span class="operator">-</span><span class="operator">-</span><span class="operator">-</span><span class="operator">-</span>rocks<span class="operator">!</span><span class="operator">-</span><span class="operator">-</span> </pre> <p><b>See also</b> <a href="qtextstream.html#padChar">padChar</a>() and <a href="qtextstream.html#setFieldWidth">setFieldWidth</a>().</p> <h3 class="fn"><a name="setRealNumberNotation" />QTextStream.setRealNumberNotation (<i>self</i>, <a href="qtextstream.html#RealNumberNotation-enum">RealNumberNotation</a> <i>notation</i>)</h3><p>Sets the real number notation to <i>notation</i> (<a href="qtextstream.html#RealNumberNotation-enum">SmartNotation</a>, <a href="qtextstream.html#RealNumberNotation-enum">FixedNotation</a>, <a href="qtextstream.html#RealNumberNotation-enum">ScientificNotation</a>). When reading and generating numbers, <a href="qtextstream.html">QTextStream</a> uses this value to detect the formatting of real numbers.</p> <p><b>See also</b> <a href="qtextstream.html#realNumberNotation">realNumberNotation</a>(), <a href="qtextstream.html#setRealNumberPrecision">setRealNumberPrecision</a>(), <a href="qtextstream.html#setNumberFlags">setNumberFlags</a>(), and <a href="qtextstream.html#setIntegerBase">setIntegerBase</a>().</p> <h3 class="fn"><a name="setRealNumberPrecision" />QTextStream.setRealNumberPrecision (<i>self</i>, int <i>precision</i>)</h3><p>Sets the precision of real numbers to <i>precision</i>. This value describes the number of fraction digits <a href="qtextstream.html">QTextStream</a> should write when generating real numbers.</p> <p>The precision cannot be a negative value. The default value is 6.</p> <p><b>See also</b> <a href="qtextstream.html#realNumberPrecision">realNumberPrecision</a>() and <a href="qtextstream.html#setRealNumberNotation">setRealNumberNotation</a>().</p> <h3 class="fn"><a name="setStatus" />QTextStream.setStatus (<i>self</i>, <a href="qtextstream.html#Status-enum">Status</a> <i>status</i>)</h3><p>Sets the status of the text stream to the <i>status</i> given.</p> <p>Subsequent calls to setStatus() are ignored until <a href="qtextstream.html#resetStatus">resetStatus</a>() is called.</p> <p>This function was introduced in Qt 4.1.</p> <p><b>See also</b> <a href="qtextstream.html#Status-enum">Status</a>, <a href="qtextstream.html#status">status</a>(), and <a href="qtextstream.html#resetStatus">resetStatus</a>().</p> <h3 class="fn"><a name="setString" />QTextStream.setString (<i>self</i>, QString <i>string</i>, <a href="qiodevice-openmode.html">QIODevice.OpenMode</a> <i>mode</i> = QIODevice.ReadWrite)</h3><p>Sets the current string to <i>string</i>, using the given <i>openMode</i>. If a device has already been assigned, <a href="qtextstream.html">QTextStream</a> will call <a href="qtcore.html#flush">flush</a>() before replacing it.</p> <p><b>See also</b> <a href="qtextstream.html#string">string</a>() and <a href="qtextstream.html#setDevice">setDevice</a>().</p> <h3 class="fn"><a name="skipWhiteSpace" />QTextStream.skipWhiteSpace (<i>self</i>)</h3><p>Reads and discards whitespace from the stream until either a non-space character is detected, or until <a href="qtextstream.html#atEnd">atEnd</a>() returns true. This function is useful when reading a stream character by character.</p> <p>Whitespace characters are all characters for which <a href="qchar.html#isSpace">QChar.isSpace</a>() returns true.</p> <p><b>See also</b> <a href="qtextstream.html#operator-gt-gt">operator>></a>().</p> <h3 class="fn"><a name="status" /><a href="qtextstream.html#Status-enum">Status</a> QTextStream.status (<i>self</i>)</h3><p>Returns the status of the text stream.</p> <p><b>See also</b> <a href="qtextstream.html#Status-enum">QTextStream.Status</a>, <a href="qtextstream.html#setStatus">setStatus</a>(), and <a href="qtextstream.html#resetStatus">resetStatus</a>().</p> <h3 class="fn"><a name="string" />QString QTextStream.string (<i>self</i>)</h3><p>Returns the current string assigned to the <a href="qtextstream.html">QTextStream</a>, or 0 if no string has been assigned.</p> <p><b>See also</b> <a href="qtextstream.html#setString">setString</a>() and <a href="qtextstream.html#device">device</a>().</p> <h3 class="fn"><a name="__lshift__" /><a href="qtextstream.html">QTextStream</a> __lshift__ (<i>self</i>, <a href="qdomnode.html">QDomNode</a>)</h3><p>This method is only available if the QtXml module is imported.</p><h3 class="fn"><a name="__lshift__-21" /><a href="qtextstream.html">QTextStream</a> __lshift__ (<i>self</i>, <a href="qsplitter.html">QSplitter</a>)</h3><p>This method is only available if the QtGui module is imported.</p><h3 class="fn"><a name="__rshift__-21" /><a href="qtextstream.html">QTextStream</a> __rshift__ (<i>self</i>, <a href="qsplitter.html">QSplitter</a>)</h3><p>This method is only available if the QtGui module is imported.</p><h3 class="fn"><a name="__lshift__" /><a href="qtextstream.html">QTextStream</a> QTextStream.__lshift__ (<i>self</i>, float <i>f</i>)</h3><h3 class="fn"><a name="__lshift__-2" /><a href="qtextstream.html">QTextStream</a> QTextStream.__lshift__ (<i>self</i>, bool <i>b</i>)</h3><h3 class="fn"><a name="__lshift__-3" /><a href="qtextstream.html">QTextStream</a> QTextStream.__lshift__ (<i>self</i>, int <i>i</i>)</h3><h3 class="fn"><a name="__lshift__-4" /><a href="qtextstream.html">QTextStream</a> QTextStream.__lshift__ (<i>self</i>, int <i>i</i>)</h3><h3 class="fn"><a name="__lshift__-5" /><a href="qtextstream.html">QTextStream</a> QTextStream.__lshift__ (<i>self</i>, int <i>i</i>)</h3><h3 class="fn"><a name="__lshift__-6" /><a href="qtextstream.html">QTextStream</a> QTextStream.__lshift__ (<i>self</i>, QString <i>s</i>)</h3><h3 class="fn"><a name="__lshift__-7" /><a href="qtextstream.html">QTextStream</a> QTextStream.__lshift__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>array</i>)</h3><h3 class="fn"><a name="__lshift__-8" /><a href="qtextstream.html">QTextStream</a> QTextStream.__lshift__ (<i>self</i>, QTextStreamManipulator <i>m</i>)</h3><h3 class="fn"><a name="__rshift__" /><a href="qtextstream.html">QTextStream</a> QTextStream.__rshift__ (<i>self</i>, QChar <i>ch</i>)</h3><h3 class="fn"><a name="__rshift__-2" /><a href="qtextstream.html">QTextStream</a> QTextStream.__rshift__ (<i>self</i>, QString <i>s</i>)</h3><h3 class="fn"><a name="__rshift__-3" /><a href="qtextstream.html">QTextStream</a> QTextStream.__rshift__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a> <i>array</i>)</h3><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>