l - l. Function Meaning bin sets the QTextStream to read/write binary numbers oct sets the QTextStream to read/write octal numbers dec sets the QTextStream to read/write decimal numbers hex sets the QTextStream to read/write hexadecimal numbers endl forces a line break flush forces the TQIODevice to flush any buffered data ws eats any available whitespace (on input) reset resets the QTextStream to its default mode (see reset()) qSetW(int) sets the field width to the given argument qSetFill(int) sets the fill character to the given argument qSetPrecision(int)
\fBWarning:\fR By default QTextStream will automatically detect whether integers in the stream are in decimal, octal, hexadecimal or binary format when reading from the stream. In particular, a leading '0' signifies octal, i.e. the sequence "0100" will be interpreted as 64.
.PP
The QTextStream class reads and writes text; it is not appropriate for dealing with binary data (but QDataStream is).
By default, output of Unicode text (i.e. TQString) is done using the local 8-bit encoding. This can be changed using the setEncoding() method. For input, the QTextStream will auto-detect standard Unicode "byte order marked" text files; otherwise the local 8-bit encoding is used.
The TQIODevice is set in the constructor, or later using setDevice(). If the end of the input is reached atEnd() returns TRUE. Data can be read into variables of the appropriate type using the operator>>() overloads, or read in its entirety into a single string using read(), or read a line at a time using readLine(). Whitespace can be skipped over using skipWhiteSpace(). You can set flags for the stream using flags() or setf(). The stream also supports width(), precision() and fill(); use reset() to reset the defaults.
.SH "QTextStream::QTextStream ( TQString * str, int filemode )"
Constructs a text stream that operates on the Unicode TQString, \fIstr\fR, through an internal device. The \fIfilemode\fR argument is passed to the device's open() function; see TQIODevice::mode().
Writing data to the text stream will modify the contents of the string. The string will be expanded when data is written beyond the end of the string. Note that the string will not be truncated:
Constructs a text stream that operates on the byte array, \fIa\fR, through an internal QBuffer device. The \fImode\fR argument is passed to the device's open() function; see TQIODevice::mode().
Constructs a text stream that operates on an existing file handle \fIfh\fR through an internal QFile device. The \fImode\fR argument is passed to the device's open() function; see TQIODevice::mode().
Note that if you create a QTextStream \fCcout\fR or another name that is also used for another variable of a different type, some linkers may confuse the two variables, which will often cause crashes.
Returns the fill character. The default value is ' ' (space).
.SH "int QTextStream::fill ( int f )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets the fill character to \fIf\fR. Returns the previous fill character.
.SH "int QTextStream::flags () const"
Returns the current stream flags. The default value is 0.
.PP
<center>.nf
.TS
l
-
l.
Flag Meaning
Not currently used; whitespace always skipped
Numeric fields are left-aligned
Not currently used (by default, numerics are right-aligned)
Puts any padding spaces between +/- and value
Output \fIand\fR input only in binary
Output \fIand\fR input only in octal
Output \fIand\fR input only in decimal
Output \fIand\fR input only in hexadecimal
Annotates numeric outputs with 0b, 0, or 0x if in
Not currently used
Uses 0B and 0X rather than 0b and 0x
Shows + for positive numeric values
Uses scientific notation for floating point values
.TE
.fi
</center>
.PP
Note that unless \fCbin\fR, \fCoct\fR, \fCdec\fR, or \fChex\fR is set, the input base is octal if the value starts with 0, hexadecimal if it starts with 0x, binary if it starts with 0b, and decimal otherwise.
.PP
See also setf() and unsetf().
.SH "int QTextStream::flags ( int f )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets the stream flags to \fIf\fR. Returns the previous stream flags.
Reads a char \fIc\fR from the stream and returns a reference to the stream. Note that whitespace is \fInot\fR skipped.
.SH "QTextStream & QTextStream::operator>> ( char & c )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Reads a char \fIc\fR from the stream and returns a reference to the stream. Note that whitespace is skipped.
.SH "QTextStream & QTextStream::operator>> ( signed short & i )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Reads a signed \fCshort\fR integer \fIi\fR from the stream and returns a reference to the stream. See flags() for an explanation of the expected input format.
.SH "QTextStream & QTextStream::operator>> ( unsigned short & i )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Reads an unsigned \fCshort\fR integer \fIi\fR from the stream and returns a reference to the stream. See flags() for an explanation of the expected input format.
.SH "QTextStream & QTextStream::operator>> ( signed int & i )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Reads a signed \fCint\fR \fIi\fR from the stream and returns a reference to the stream. See flags() for an explanation of the expected input format.
.SH "QTextStream & QTextStream::operator>> ( unsigned int & i )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Reads an unsigned \fCint\fR \fIi\fR from the stream and returns a reference to the stream. See flags() for an explanation of the expected input format.
.SH "QTextStream & QTextStream::operator>> ( signed long & i )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Reads a signed \fClong\fR int \fIi\fR from the stream and returns a reference to the stream. See flags() for an explanation of the expected input format.
.SH "QTextStream & QTextStream::operator>> ( unsigned long & i )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Reads an unsigned \fClong\fR int \fIi\fR from the stream and returns a reference to the stream. See flags() for an explanation of the expected input format.
.SH "QTextStream & QTextStream::operator>> ( float & f )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Reads a \fCfloat\fR \fIf\fR from the stream and returns a reference to the stream. See flags() for an explanation of the expected input format.
.SH "QTextStream & QTextStream::operator>> ( double & f )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Reads a \fCdouble\fR \fIf\fR from the stream and returns a reference to the stream. See flags() for an explanation of the expected input format.
.SH "QTextStream & QTextStream::operator>> ( char * s )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Reads a "word" from the stream into \fIs\fR and returns a reference to the stream.
.PP
A word consists of characters for which isspace() returns FALSE.
The returned string does not contain any trailing newline or carriage return. Note that this is different from TQIODevice::readLine(), which does not strip the newline at the end of the line.
l - l. Encoding Meaning Locale Uses local file format (Latin1 if locale is not set), but autodetecting Unicode(utf16) on input. Unicode Uses Unicode(utf16) for input and output. Output will be written in the order most efficient for the current platform (i.e. the order used internally in TQString). UnicodeUTF8 Using Unicode(utf8) for input and output. If you use it for input it will autodetect utf16 and use it instead of utf8. Latin1 ISO-8859-1. Will not autodetect utf16. UnicodeNetworkOrder Uses network order Unicode(utf16) for input and output. Useful when reading Unicode data that does not start with the byte order marker. UnicodeReverse Uses reverse network order Unicode(utf16) for input and output. Useful when reading Unicode data that does not start with the byte order marker or when writing data that should be read by buggy Windows applications. RawUnicode
Locale and all Unicode encodings, except RawUnicode, will look at the first two bytes in an input stream to determine the byte order. The initial byte order marker will be stripped off before data is read.
.PP
Note that this function should be called before any data is read to or written from the stream.
.PP
See also setCodec().
.PP
Examples:
.)l addressbook/centralwidget.cpp, network/httpd/httpd.cpp, and qwerty/qwerty.cpp.
.SH "int QTextStream::setf ( int bits )"
Sets the stream flag bits \fIbits\fR. Returns the previous stream flags.
.PP
Equivalent to \fCflags( flags() | bits )\fR.
.PP
See also unsetf().
.SH "int QTextStream::setf ( int bits, int mask )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets the stream flag bits \fIbits\fR with a bit mask \fImask\fR. Returns the previous stream flags.