📄 qtextstream.3qt
字号:
QTextStream cin ( stdin, IO_ReadOnly );.br QTextStream cerr( stderr, IO_WriteOnly );.fi.SH "QTextStream::QTextStream ( QByteArray a, int mode )"Constructs a text stream that operates on a byte array through an internal QBuffer device..PPExample:.PP.nf.br QByteArray array;.br QTextStream ts( array, IO_WriteOnly );.br ts << "pi = " << 3.14 << '\\0'; // array == "pi = 3.14".fi.PPWriting data to the text stream will modify the contents of the array. The array will be expanded when data is written beyond the end of the string..PPSame example, using a QBuffer:.PP.nf.br QByteArray array;.br QBuffer buf( array );.br buf.open( IO_WriteOnly );.br QTextStream ts( &buf );.br ts << "pi = " << 3.14 << '\\0'; // array == "pi = 3.14".br buf.close();.fi.SH "QTextStream::~QTextStream () \fC[virtual]\fR"Destroys the text stream..PPThe destructor does not affect the current IO device..SH "bool QTextStream::atEnd () const"Returns TRUE if the IO device has reached the end position (end of stream or file) or if there is no IO device set..PPReturns FALSE if the current position of the read/write head of the IO device is somewhere before the end position..PPSee also: QIODevice::atEnd()..SH "QIODevice * QTextStream::device () const"Returns the IO device currently set..PPSee also: setDevice() and unsetDevice()..SH "bool QTextStream::eof () const"\fBThis function is obsolete.\fR It is provided to keep old programs working. We strongly advise against using it in new code..PPThis function has been renamed to atEnd()..PPSee also: QIODevice::atEnd()..PPExamples:.(lgrapher/grapher.cpp.)l.SH "int QTextStream::fill () const"Returns the fill character. The default value is ' ' (space)..SH "int QTextStream::fill ( int f )"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..PPThe meaning of the flags are:.TP\fIskipws\fR - Not currently used - whitespace always skipped.TP\fIleft\fR - Numeric fields are left-aligned.TP\fIright\fR - Not currently used (by default numerics are right aligned).TP\fIinternal\fR - Put any padding spaces between +/- and value.TP\fIbin\fR - Output \fIand\fR input only in binary.TP\fIoct\fR - Output \fIand\fR input only in octal.TP\fIdec\fR - Output \fIand\fR input only in decimal.TP\fIhex\fR - Output \fIand\fR input only in hexadecimal.TP\fIshowbase\fR - Annotate numeric outputs with 0b, 0, or 0x if in \fIbin, oct,\fR or \fIhex\fR format.TP\fIshowpoint\fR - Not currently used.TP\fIuppercase\fR - Use 0B and 0X rather than 0b and 0x.TP\fIshowpos\fR - Show + for positive numeric values.TP\fIscientific\fR - Use scientific notation for floating point values.TP\fIfixed\fR - Use fixed-point notation for floating point values.PPNote that unless \fIbin, oct, dec,\fR or \fIhex\fR is set, the input base is octal if the value starts with 0, hexadecimal if it starts with 0x, binary if the value starts with 0b, and decimal otherwise..PPSee also: setf() and unsetf()..SH "int QTextStream::flags ( int f )"Sets the stream flags to \fIf.\fR Returns the previous stream flags..PPSee also: setf(), unsetf() and flags()..SH "QTextStream & QTextStream::operator<< ( char c )"Writes a \fCchar\fR to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( const QString & s )"Writes a string to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( const char * s )"Writes a string to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( double f )"Writes a \fCdouble\fR to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( float f )"Writes a \fCfloat\fR to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( signed int i )"Writes an \fCint\fR to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( signed long i )"Writes a \fClong int\fR to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( signed short i )"Writes a \fCshort\fR integer to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( unsigned int i )"Writes an \fCunsigned int\fR to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( unsigned long i )"Writes an \fCunsigned long int\fR to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( unsigned short i )"Writes an \fCunsigned short\fR integer to the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator<< ( void * ptr )"Writes a pointer to the stream and returns a reference to the stream..PPThe \fIptr\fR is output as an unsigned long hexadecimal integer..SH "QTextStream & QTextStream::operator>> ( QChar & c )"Reads a \fCchar\fR from the stream and returns a reference to the stream. Note that whitespace is \\em not skipped..SH "QTextStream & QTextStream::operator>> ( QCString & str )"Reads a word from the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator>> ( QString & str )"Reads a word from the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator>> ( char & c )"Reads a \fCchar\fR from the stream and returns a reference to the stream. Note that whitespace is skipped..SH "QTextStream & QTextStream::operator>> ( char * s )"Reads a word from the stream and returns a reference to the stream..SH "QTextStream & QTextStream::operator>> ( double & f )"Reads a \fCdouble\fR from the stream and returns a reference to the stream. See flags() for an explanation of expected input format..SH "QTextStream & QTextStream::operator>> ( float & f )"Reads a \fCfloat\fR from the stream and returns a reference to the stream. See flags() for an explanation of expected input format..SH "QTextStream & QTextStream::operator>> ( signed int & i )"Reads a signed \fCint\fR from the stream and returns a reference to the stream. See flags() for an explanation of expected input format..SH "QTextStream & QTextStream::operator>> ( signed long & i )"Reads a signed \fClong\fR int from the stream and returns a reference to the stream. See flags() for an explanation of expected input format..SH "QTextStream & QTextStream::operator>> ( signed short & i )"Reads a signed \fCshort\fR integer from the stream and returns a reference to the stream. See flags() for an explanation of expected input format..SH "QTextStream & QTextStream::operator>> ( unsigned int & i )"Reads an unsigned \fCint\fR from the stream and returns a reference to the stream. See flags() for an explanation of expected input format..SH "QTextStream & QTextStream::operator>> ( unsigned long & i )"Reads an unsigned \fClong\fR int from the stream and returns a reference to the stream. See flags() for an explanation of expected input format..SH "QTextStream & QTextStream::operator>> ( unsigned short & i )"Reads an unsigned \fCshort\fR integer from the stream and returns a reference to the stream. See flags() for an explanation of expected input format..SH "int QTextStream::precision () const"Returns the precision. The default value is 6..SH "int QTextStream::precision ( int p )"Sets the precision to \fIp.\fR Returns the previous precision setting..SH "QString QTextStream::read ()"Reads the entire stream and returns a string containing the text..PPSee also: QIODevice::readLine()..SH "QString QTextStream::readLine ()"Reads a line from the stream and returns a string containing the text..PPThe returned string does not contain any trailing newline or carriage return. Note that this is different from QIODevice::readLine(), which does not strip the newline at the end of the line..PPSee also: QIODevice::readLine()..SH "QTextStream & QTextStream::readRawBytes ( char * s, uint len )"Reads \fIlen\fR bytes from the stream into \fIe\fR s and returns a reference to the stream..PPThe buffer \fIs\fR must be preallocated..PP\\note No Encoding is done by this function..PP\fBWarning:\fR The behaviour of this function is undefined unless the stream's encoding is set to Unicode or Latin1..PPSee also: QIODevice::readBlock()..SH "void QTextStream::reset ()"Resets the text stream..TPAll flags are set to 0..TPThe field width is set to 0..TPThe fill character is set to ' ' (space)..TPThe precision is set to 6..PPSee also: setf(), width(), fill() and precision()..SH "void QTextStream::setCodec ( QTextCodec * codec )"Sets the codec for this stream to \fIcodec.\fR Will not try to autodetect Unicode..PP\\note This function should be called before any data is read to/written from the stream..PPSee also: setEncoding..SH "void QTextStream::setDevice ( QIODevice * d )"Sets the IO device to \fId.\fR.PPSee also: device() and unsetDevice()..SH "void QTextStream::setEncoding ( Encoding e )"Sets the encoding of this stream to \fIe,\fR where \fIe\fR is one of:.TP\fCLocale\fR Using local file format (Latin1 if locale is not set), but autodetecting Unicode(utf16) on input..TP\fCUnicode\fR Using 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 QString)..TP\fCLatin1\fR ISO-8859-1. Will not autodetect utf16..TP\fCUnicodeNetworkOrder\fR Using network order Unicode(utf16) for input and output. Useful when reading Unicode data that does not start with the byte order marker..TP\fCUnicodeReverse\fR Using reverse network order Unicode(utf16) for input and output. Useful when reading Unicode data that does not start with the byte order marker, or writing data that should be read by buggy Windows applications..TP\fCRawUnicode\fR Like Unicode, but does not write the byte order marker, nor does it autodetect the byte order. Only useful when writing to non-persistent storage used by a single process..PP\fCLocale\fR and all Unicode encodings, except \fCRawUnicode,\fR will look at the first two bytes in a input stream to determine the byte order. The initial byte order marker will be stripped off before data is read..PP\\note This function should be called before any data is read to/written from the stream..PPSee also: setCodec..SH "int QTextStream::setf ( int bits )"Sets the stream flag bits \fIbits.\fR Returns the previous stream flags..PPEquivalent to \fCflags( flags() | bits )\fR..PPSee also: setf() and unsetf()..SH "int QTextStream::setf ( int bits, int mask )"Sets the stream flag bits \fIbits\fR with a bit mask \fImask.\fR Returns the previous stream flags..PPEquivalent to \fCflags( (flags() & ~mask) | (bits & mask) )\fR..PPSee also: setf() and unsetf()..SH "void QTextStream::skipWhiteSpace ()"Equivalent to *this << ws..SH "void QTextStream::unsetDevice ()"Unsets the IO device. Equivalent to setDevice( 0 )..PPSee also: device() and setDevice()..SH "int QTextStream::unsetf ( int bits )"Clears the stream flag bits \fIbits.\fR Returns the previous stream flags..PPEquivalent to \fCflags( flags() & ~mask )\fR..PPSee also: setf()..SH "int QTextStream::width () const"Returns the field width. The default value is 0..SH "int QTextStream::width ( int w )"Sets the field width to \fIw.\fR Returns the previous field width..SH "QTextStream & QTextStream::writeRawBytes ( const char * s, uint len )"Writes the \fIlen\fR bytes from \fIs\fR to the stream and returns a reference to the stream..PP\\note No Encoding is done by this function..PPSee also: QIODevice::writeBlock()..SH "SEE ALSO".BR http://www.troll.no/qt/qtextstream.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS. See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -