
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQTextStream class provides a convenient interface for reading and writing text.More...
| Header: | #include <QTextStream> |
| Inherited By: |
Note: All functions in this class arereentrant.
| enum | FieldAlignment { AlignLeft, AlignRight, AlignCenter, AlignAccountingStyle } |
| enum | NumberFlag { ShowBase, ForcePoint, ForceSign, UppercaseBase, UppercaseDigits } |
| flags | NumberFlags |
| enum | RealNumberNotation { ScientificNotation, FixedNotation, SmartNotation } |
| enum | Status { Ok, ReadPastEnd, ReadCorruptData, WriteFailed } |
| QTextStream() | |
| QTextStream(QIODevice * device) | |
| QTextStream(FILE * fileHandle, QIODevice::OpenMode openMode = QIODevice::ReadWrite) | |
| QTextStream(QString * string, QIODevice::OpenMode openMode = QIODevice::ReadWrite) | |
| QTextStream(QByteArray * array, QIODevice::OpenMode openMode = QIODevice::ReadWrite) | |
| QTextStream(const QByteArray & array, QIODevice::OpenMode openMode = QIODevice::ReadOnly) | |
| virtual | ~QTextStream() |
| bool | atEnd() const |
| bool | autoDetectUnicode() const |
| QTextCodec * | codec() const |
| QIODevice * | device() const |
| FieldAlignment | fieldAlignment() const |
| int | fieldWidth() const |
| void | flush() |
| bool | generateByteOrderMark() const |
| int | integerBase() const |
| QLocale | locale() const |
| NumberFlags | numberFlags() const |
| QChar | padChar() const |
| qint64 | pos() const |
| QString | read(qint64 maxlen) |
| QString | readAll() |
| QString | readLine(qint64 maxlen = 0) |
| RealNumberNotation | realNumberNotation() const |
| int | realNumberPrecision() const |
| void | reset() |
| void | resetStatus() |
| bool | seek(qint64 pos) |
| void | setAutoDetectUnicode(bool enabled) |
| void | setCodec(QTextCodec * codec) |
| void | setCodec(const char * codecName) |
| void | setDevice(QIODevice * device) |
| void | setFieldAlignment(FieldAlignment mode) |
| void | setFieldWidth(int width) |
| void | setGenerateByteOrderMark(bool generate) |
| void | setIntegerBase(int base) |
| void | setLocale(const QLocale & locale) |
| void | setNumberFlags(NumberFlags flags) |
| void | setPadChar(QChar ch) |
| void | setRealNumberNotation(RealNumberNotation notation) |
| void | setRealNumberPrecision(int precision) |
| void | setStatus(Status status) |
| void | setString(QString * string, QIODevice::OpenMode openMode = QIODevice::ReadWrite) |
| void | skipWhiteSpace() |
| Status | status() const |
| QString * | string() const |
| QTextStream & | operator<<(QChar c) |
| QTextStream & | operator<<(signed short i) |
| QTextStream & | operator<<(float f) |
| QTextStream & | operator<<(const QString & string) |
| QTextStream & | operator<<(char c) |
| QTextStream & | operator<<(unsigned short i) |
| QTextStream & | operator<<(signed int i) |
| QTextStream & | operator<<(unsigned int i) |
| QTextStream & | operator<<(signed long i) |
| QTextStream & | operator<<(unsigned long i) |
| QTextStream & | operator<<(qlonglong i) |
| QTextStream & | operator<<(qulonglong i) |
| QTextStream & | operator<<(double f) |
| QTextStream & | operator<<(const QByteArray & array) |
| QTextStream & | operator<<(const char * string) |
| QTextStream & | operator<<(const void * ptr) |
| QTextStream & | operator>>(QChar & c) |
| QTextStream & | operator>>(signed short & i) |
| QTextStream & | operator>>(float & f) |
| QTextStream & | operator>>(QString & str) |
| QTextStream & | operator>>(char & c) |
| QTextStream & | operator>>(unsigned short & i) |
| QTextStream & | operator>>(signed int & i) |
| QTextStream & | operator>>(unsigned int & i) |
| QTextStream & | operator>>(signed long & i) |
| QTextStream & | operator>>(unsigned long & i) |
| QTextStream & | operator>>(qlonglong & i) |
| QTextStream & | operator>>(qulonglong & i) |
| QTextStream & | operator>>(double & f) |
| QTextStream & | operator>>(QByteArray & array) |
| QTextStream & | operator>>(char * c) |
| QTextStream & | bin(QTextStream & stream) |
| QTextStream & | bom(QTextStream & stream) |
| QTextStream & | center(QTextStream & stream) |
| QTextStream & | dec(QTextStream & stream) |
| QTextStream & | endl(QTextStream & stream) |
| QTextStream & | fixed(QTextStream & stream) |
| QTextStream & | flush(QTextStream & stream) |
| QTextStream & | forcepoint(QTextStream & stream) |
| QTextStream & | forcesign(QTextStream & stream) |
| QTextStream & | hex(QTextStream & stream) |
| QTextStream & | left(QTextStream & stream) |
| QTextStream & | lowercasebase(QTextStream & stream) |
| QTextStream & | lowercasedigits(QTextStream & stream) |
| QTextStream & | noforcepoint(QTextStream & stream) |
| QTextStream & | noforcesign(QTextStream & stream) |
| QTextStream & | noshowbase(QTextStream & stream) |
| QTextStream & | oct(QTextStream & stream) |
| QTextStreamManipulator | qSetFieldWidth(int width) |
| QTextStreamManipulator | qSetPadChar(QChar ch) |
| QTextStreamManipulator | qSetRealNumberPrecision(int precision) |
| QTextStream & | reset(QTextStream & stream) |
| QTextStream & | right(QTextStream & stream) |
| QTextStream & | scientific(QTextStream & stream) |
| QTextStream & | showbase(QTextStream & stream) |
| QTextStream & | uppercasebase(QTextStream & stream) |
| QTextStream & | uppercasedigits(QTextStream & stream) |
| QTextStream & | ws(QTextStream & stream) |
TheQTextStream class provides a convenient interface for reading and writing text.
QTextStream can operate on aQIODevice, aQByteArray or aQString. UsingQTextStream'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:
QFile data("output.txt");if (data.open(QFile::WriteOnly|QFile::Truncate)) {QTextStream out(&data); out<<"Result: "<<qSetFieldWidth(10)<< left<<3.14<<2.7;// writes "Result: 3.14 2.7 "}
It's also common to useQTextStream to read console input and write console output.QTextStream is locale aware, and will automatically decode standard input using the correct codec. Example:
QTextStream stream(stdin);QString line;do { line= stream.readLine();}while (!line.isNull());
Besides usingQTextStream's constructors, you can also set the device or stringQTextStream operates on by callingsetDevice() orsetString(). You can seek to a position by callingseek(), andatEnd() will return true when there is no data left to be read. If you callflush(),QTextStream will empty all data from its write buffer into the device and callflush() on the device.
Internally,QTextStream uses a Unicode based buffer, andQTextCodec is used byQTextStream to automatically support different character sets. By default,QTextCodec::codecForLocale() is used for reading and writing, but you can also set the codec by callingsetCodec(). 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 callingsetGenerateByteOrderMark(true). WhenQTextStream operates on aQString directly, the codec is disabled.
There are three general ways to useQTextStream when reading text files:
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 aQFile and read from it directly usingQFile::readLine() instead of using the stream, the text stream's internal position will be out of sync with the file's position.
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 callingsetIntegerBase(). Example:
QTextStream in("0x50 0x20");int firstNumber, secondNumber;in>> firstNumber;// firstNumber == 80in>> dec>> secondNumber;// secondNumber == 0char ch;in>> ch;// ch == 'x'
QTextStream supports many formatting options for generating text. You can set the field width and pad character by callingsetFieldWidth() andsetPadChar(). UsesetFieldAlignment() to set the alignment within each field. For real numbers, callsetRealNumberNotation() andsetRealNumberPrecision() to set the notation (SmartNotation,ScientificNotation,FixedNotation) and precision in digits of the generated number. Some extra number formatting options are also available throughsetNumberFlags().
Like<iostream> in the standard C++ library,QTextStream also defines several global manipulator functions:
In addition, Qt provides three global manipulators that take a parameter:qSetFieldWidth(),qSetPadChar(), andqSetRealNumberPrecision().
See alsoQDataStream,QIODevice,QFile,QBuffer,QTcpSocket, andCodecs Example.
This enum specifies how to align text in fields when the field is wider than the text that occupies it.
| Constant | Value | Description |
|---|---|---|
QTextStream::AlignLeft | 0 | Pad on the right side of fields. |
QTextStream::AlignRight | 1 | Pad on the left side of fields. |
QTextStream::AlignCenter | 2 | Pad on both sides of field. |
QTextStream::AlignAccountingStyle | 3 | Same as AlignRight, except that the sign of a number is flush left. |
See alsosetFieldAlignment().
This enum specifies various flags that can be set to affect the output of integers,floats, anddoubles.
| Constant | Value | Description |
|---|---|---|
QTextStream::ShowBase | 0x1 | Show the base as a prefix if the base is 16 ("0x"), 8 ("0"), or 2 ("0b"). |
QTextStream::ForcePoint | 0x2 | Always put the decimal separator in numbers, even if there are no decimals. |
QTextStream::ForceSign | 0x4 | Always put the sign in numbers, even for positive numbers. |
QTextStream::UppercaseBase | 0x8 | Use uppercase versions of base prefixes ("0X", "0B"). |
QTextStream::UppercaseDigits | 0x10 | Use uppercase letters for expressing digits 10 to 35 instead of lowercase. |
The NumberFlags type is a typedef forQFlags<NumberFlag>. It stores an OR combination of NumberFlag values.
See alsosetNumberFlags().
This enum specifies which notations to use for expressingfloat anddouble as strings.
| Constant | Value | Description |
|---|---|---|
QTextStream::ScientificNotation | 2 | Scientific notation (printf()'s%e flag). |
QTextStream::FixedNotation | 1 | Fixed-point notation (printf()'s%f flag). |
QTextStream::SmartNotation | 0 | Scientific or fixed-point notation, depending on which makes most sense (printf()'s%g flag). |
See alsosetRealNumberNotation().
This enum describes the current status of the text stream.
| Constant | Value | Description |
|---|---|---|
QTextStream::Ok | 0 | The text stream is operating normally. |
QTextStream::ReadPastEnd | 1 | The text stream has read past the end of the data in the underlying device. |
QTextStream::ReadCorruptData | 2 | The text stream has read corrupt data. |
QTextStream::WriteFailed | 3 | The text stream cannot write to the underlying device. |
See alsostatus().
Constructs aQTextStream. Before you can use it for reading or writing, you must assign a device or a string.
See alsosetDevice() andsetString().
Constructs aQTextStream that operates ondevice.
Constructs aQTextStream that operates onfileHandle, usingopenMode to define the open mode. Internally, aQFile is created to handle the FILE pointer.
This constructor is useful for working directly with the common FILE based input and output streams: stdin, stdout and stderr. Example:
QString str;QTextStream in(stdin);in>> str;
Constructs aQTextStream that operates onstring, usingopenMode to define the open mode.
Constructs aQTextStream that operates onarray, usingopenMode to define the open mode. Internally, the array is wrapped by aQBuffer.
Constructs aQTextStream that operates onarray, usingopenMode to define the open mode. The array is accessed as read-only, regardless of the values inopenMode.
This constructor is convenient for working on constant strings. Example:
int main(int argc,char*argv[]){// read numeric arguments (123, 0x20, 4.5...)for (int i=1; i< argc;++i) {int number;QTextStream in(argv[i]); in>> number;... }}
[virtual]QTextStream::~QTextStream()Destroys theQTextStream.
If the stream operates on a device,flush() will be called implicitly. Otherwise, the device is unaffected.
Returns true if there is no more data to be read from theQTextStream; otherwise returns false. This is similar to, but not the same as callingQIODevice::atEnd(), asQTextStream also takes into account its internal Unicode buffer.
Returns true if automatic Unicode detection is enabled, otherwise returns false. Automatic Unicode detection is enabled by default.
See alsosetAutoDetectUnicode() andsetCodec().
Returns the codec that is current assigned to the stream.
See alsosetCodec(),setAutoDetectUnicode(), andlocale().
Returns the current device associated with theQTextStream, or 0 if no device has been assigned.
See alsosetDevice() andstring().
Returns the current field alignment.
See alsosetFieldAlignment() andfieldWidth().
Returns the current field width.
See alsosetFieldWidth().
Flushes any buffered data waiting to be written to the device.
IfQTextStream operates on a string, this function does nothing.
Returns true ifQTextStream 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.
See alsosetGenerateByteOrderMark().
Returns the current base of integers. 0 means that the base is detected when reading, or 10 (decimal) when generating numbers.
See alsosetIntegerBase(),QString::number(), andnumberFlags().
Returns the locale for this stream. The default locale is C.
This function was introduced in Qt 4.5.
See alsosetLocale().
Returns the current number flags.
See alsosetNumberFlags(),integerBase(), andrealNumberNotation().
Returns the current pad character.
See alsosetPadChar() andsetFieldWidth().
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).
BecauseQTextStream 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.
This function was introduced in Qt 4.2.
See alsoseek().
Reads at mostmaxlen characters from the stream, and returns the data read as aQString.
This function was introduced in Qt 4.1.
See alsoreadAll(),readLine(), andQIODevice::read().
Reads the entire content of the stream, and returns it as aQString. Avoid this function when working on large files, as it will consume a significant amount of memory.
CallingreadLine() is better if you do not know how much data is available.
See alsoreadLine().
Reads one line of text from the stream, and returns it as aQString. The maximum allowed line length is set tomaxlen. If the stream contains lines longer than this, then the lines will be split aftermaxlen characters and returned in parts.
Ifmaxlen is 0, the lines can be of any length. A common value formaxlen is 75.
The returned line has no trailing end-of-line characters ("\n" or "\r\n"), so callingQString::trimmed() is unnecessary.
If the stream has read to the end of the file, readLine() will return a nullQString. For strings, or for devices that support it, you can explicitly test for the end of the stream usingatEnd().
See alsoreadAll() andQIODevice::readLine().
Returns the current real number notation.
See alsosetRealNumberNotation(),realNumberPrecision(),numberFlags(), andintegerBase().
Returns the current real number precision, or the number of fraction digitsQTextStream will write when generating real numbers.
See alsosetRealNumberPrecision(),setRealNumberNotation(),realNumberNotation(),numberFlags(), andintegerBase().
ResetsQTextStream's formatting options, bringing it back to its original constructed state. The device, string and any buffered data is left untouched.
Resets the status of the text stream.
This function was introduced in Qt 4.1.
See alsoQTextStream::Status,status(), andsetStatus().
Seeks to the positionpos in the device. Returns true on success; otherwise returns false.
Ifenabled is true,QTextStream 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,QTextStream will replace the current codec with the UTF codec.
This function can be used together withsetCodec(). It is common to set the codec to UTF-8, and then enable UTF-16 detection.
See alsoautoDetectUnicode() andsetCodec().
Sets the codec for this stream tocodec. 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,QTextCodec::codecForLocale() is used, and automatic unicode detection is enabled.
IfQTextStream operates on a string, this function does nothing.
Warning: 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.
See alsocodec(),setAutoDetectUnicode(), andsetLocale().
Sets the codec for this stream to theQTextCodec for the encoding specified bycodecName. Common values forcodecName include "ISO 8859-1", "UTF-8", and "UTF-16". If the encoding isn't recognized, nothing happens.
Example:
QTextStream out(&file);out.setCodec("UTF-8");
See alsoQTextCodec::codecForName() andsetLocale().
Sets the current device todevice. If a device has already been assigned,QTextStream will callflush() before the old device is replaced.
Note:This function resets locale to the default locale ('C') and codec to the default codec,QTextCodec::codecForLocale().
See alsodevice() andsetString().
Sets the field alignment tomode. When used together withsetFieldWidth(), this function allows you to generate formatted output with text aligned to the left, to the right or center aligned.
See alsofieldAlignment() andsetFieldWidth().
Sets the current field width towidth. Ifwidth is 0 (the default), the field width is equal to the length of the generated text.
Note: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.
See alsofieldWidth() andsetPadChar().
Ifgenerate is true and a UTF codec is used,QTextStream will insert the BOM (Byte Order Mark) before any data has been written to the device. Ifgenerate is false, no BOM will be inserted. This function must be called before any data is written. Otherwise, it does nothing.
See alsogenerateByteOrderMark() andbom().
Sets the base of integers tobase, both for reading and for generating numbers.base can be either 2 (binary), 8 (octal), 10 (decimal) or 16 (hexadecimal). Ifbase is 0,QTextStream will attempt to detect the base by inspecting the data on the stream. When generating numbers,QTextStream assumes base is 10 unless the base has been set explicitly.
See alsointegerBase(),QString::number(), andsetNumberFlags().
Sets the locale for this stream tolocale. The specified locale is used for conversions between numbers and their string representations.
The default locale is C and it is a special case - the thousands group separator is not used for backward compatibility reasons.
This function was introduced in Qt 4.5.
See alsolocale().
Sets the current number flags toflags.flags is a set of flags from theNumberFlag enum, and describes options for formatting generated code (e.g., whether or not to always write the base or sign of a number).
See alsonumberFlags(),setIntegerBase(), andsetRealNumberNotation().
Sets the pad character toch. The default value is the ASCII space character (' '), orQChar(0x20). This character is used to fill in the space in fields when generating text.
Example:
QString s;QTextStream out(&s);out.setFieldWidth(10);out.setFieldAlignment(QTextStream::AlignCenter);out.setPadChar('-');out<<"Qt"<<"rocks!";
The strings contains:
----Qt------rocks!--
See alsopadChar() andsetFieldWidth().
Sets the real number notation tonotation (SmartNotation,FixedNotation,ScientificNotation). When reading and generating numbers,QTextStream uses this value to detect the formatting of real numbers.
See alsorealNumberNotation(),setRealNumberPrecision(),setNumberFlags(), andsetIntegerBase().
Sets the precision of real numbers toprecision. This value describes the number of fraction digitsQTextStream should write when generating real numbers.
The precision cannot be a negative value. The default value is 6.
See alsorealNumberPrecision() andsetRealNumberNotation().
Sets the status of the text stream to thestatus given.
Subsequent calls to setStatus() are ignored untilresetStatus() is called.
This function was introduced in Qt 4.1.
See alsoStatus,status(), andresetStatus().
Sets the current string tostring, using the givenopenMode. If a device has already been assigned,QTextStream will callflush() before replacing it.
See alsostring() andsetDevice().
Reads and discards whitespace from the stream until either a non-space character is detected, or untilatEnd() returns true. This function is useful when reading a stream character by character.
Whitespace characters are all characters for whichQChar::isSpace() returns true.
See alsooperator>>().
Returns the status of the text stream.
See alsoQTextStream::Status,setStatus(), andresetStatus().
Returns the current string assigned to theQTextStream, or 0 if no string has been assigned.
See alsosetString() anddevice().
Writes the characterc to the stream, then returns a reference to theQTextStream.
See alsosetFieldWidth().
Writes the integer numberi to the stream, then returns a reference to theQTextStream. By default, the number is stored in decimal form, but you can also set the base by callingsetIntegerBase().
See alsosetFieldWidth() andsetNumberFlags().
Writes the real numberf to the stream, then returns a reference to theQTextStream. By default,QTextStream stores it usingSmartNotation, with up to 6 digits of precision. You can change the textual representationQTextStream will use for real numbers by callingsetRealNumberNotation(),setRealNumberPrecision() andsetNumberFlags().
See alsosetFieldWidth(),setRealNumberNotation(),setRealNumberPrecision(), andsetNumberFlags().
Writes the stringstring to the stream, and returns a reference to theQTextStream. The string is first encoded using the assigned codec (the default codec isQTextCodec::codecForLocale()) before it is written to the stream.
See alsosetFieldWidth() andsetCodec().
This is an overloaded function.
Convertsc from ASCII to aQChar, then writes it to the stream.
This is an overloaded function.
Writes the unsigned shorti to the stream.
This is an overloaded function.
Writes the signed inti to the stream.
This is an overloaded function.
Writes the unsigned inti to the stream.
This is an overloaded function.
Writes the signed longi to the stream.
This is an overloaded function.
Writes the unsigned longi to the stream.
This is an overloaded function.
Writes the qlonglongi to the stream.
This is an overloaded function.
Writes the qulonglongi to the stream.
This is an overloaded function.
Writes the doublef to the stream.
This is an overloaded function.
Writesarray to the stream. The contents ofarray are converted withQString::fromAscii().
This is an overloaded function.
Writes the constant string pointed to bystring to the stream.string is assumed to be in ISO-8859-1 encoding. This operator is convenient when working with constant string data. Example:
QTextStream out(stdout);out<<"Qt rocks!"<< endl;
Warning:QTextStream assumes thatstring points to a string of text, terminated by a '\0' character. If there is no terminating '\0' character, your application may crash.
This is an overloaded function.
Writesptr to the stream as a hexadecimal number with a base.
Reads a character from the stream and stores it inc. Returns a reference to theQTextStream, so several operators can be nested. Example:
QTextStream in(file);QChar ch1, ch2, ch3;in>> ch1>> ch2>> ch3;
Whitespace isnot skipped.
Reads an integer from the stream and stores it ini, then returns a reference to theQTextStream. The number is cast to the correct type before it is stored. If no number was detected on the stream,i is set to 0.
By default,QTextStream will attempt to detect the base of the number using the following rules:
| Prefix | Base |
|---|---|
| "0b" or "0B" | 2 (binary) |
| "0" followed by "0-7" | 8 (octal) |
| "0" otherwise | 10 (decimal) |
| "0x" or "0X" | 16 (hexadecimal) |
| "1" to "9" | 10 (decimal) |
By callingsetIntegerBase(), you can specify the integer base explicitly. This will disable the auto-detection, and speed upQTextStream slightly.
Leading whitespace is skipped.
Reads a real number from the stream and stores it inf, then returns a reference to theQTextStream. The number is cast to the correct type. If no real number is detect on the stream,f is set to 0.0.
As a special exception,QTextStream allows the strings "nan" and "inf" to represent NAN and INF floats or doubles.
Leading whitespace is skipped.
Reads a word from the stream and stores it instr, then returns a reference to the stream. Words are separated by whitespace (i.e., all characters for whichQChar::isSpace() returns true).
Leading whitespace is skipped.
This is an overloaded function.
Reads a character from the stream and stores it inc. The character from the stream is converted to ISO-5589-1 before it is stored.
See alsoQChar::toLatin1().
This is an overloaded function.
Stores the integer in the unsigned shorti.
This is an overloaded function.
Stores the integer in the signed inti.
This is an overloaded function.
Stores the integer in the unsigned inti.
This is an overloaded function.
Stores the integer in the signed longi.
This is an overloaded function.
Stores the integer in the unsigned longi.
This is an overloaded function.
Stores the integer in the qlonglongi.
This is an overloaded function.
Stores the integer in the qulonglongi.
This is an overloaded function.
Stores the real number in the doublef.
This is an overloaded function.
Converts the word to ISO-8859-1, then stores it inarray.
See alsoQString::toLatin1().
This is an overloaded function.
Stores the word inc, terminated by a '\0' character. If no word is available, only the '\0' character is stored.
Warning: Although convenient, this operator is dangerous and must be used with care.QTextStream assumes thatc points to a buffer with enough space to hold the word. If the buffer is too small, your application may crash.
If possible, use theQByteArray operator instead.
CallsQTextStream::setIntegerBase(2) onstream and returnsstream.
See alsooct(),dec(),hex(), andQTextStream manipulators.
Toggles insertion of the Byte Order Mark onstream whenQTextStream is used with a UTF codec.
See alsoQTextStream::setGenerateByteOrderMark() andQTextStream manipulators.
CallsQTextStream::setFieldAlignment(QTextStream::AlignCenter) onstream and returnsstream.
See alsoleft(),right(), andQTextStream manipulators.
CallsQTextStream::setIntegerBase(10) onstream and returnsstream.
See alsobin(),oct(),hex(), andQTextStream manipulators.
Writes '\n' to thestream and flushes the stream.
Equivalent to
stream<<'\n'<< flush;
Note: On Windows, all '\n' characters are written as '\r\n' ifQTextStream's device or string is opened using theQIODevice::Text flag.
See alsoflush(),reset(), andQTextStream manipulators.
CallsQTextStream::setRealNumberNotation(QTextStream::FixedNotation) onstream and returnsstream.
See alsoscientific() andQTextStream manipulators.
Calls QTextStream::flush() onstream and returnsstream.
See alsoendl(),reset(), andQTextStream manipulators.
CallsQTextStream::setNumberFlags(QTextStream::numberFlags() |QTextStream::ForcePoint) onstream and returnsstream.
See alsonoforcepoint(),forcesign(),showbase(), andQTextStream manipulators.
CallsQTextStream::setNumberFlags(QTextStream::numberFlags() |QTextStream::ForceSign) onstream and returnsstream.
See alsonoforcesign(),forcepoint(),showbase(), andQTextStream manipulators.
CallsQTextStream::setIntegerBase(16) onstream and returnsstream.
Note:The hex modifier can only be used for writing to streams.
See alsobin(),oct(),dec(), andQTextStream manipulators.
CallsQTextStream::setFieldAlignment(QTextStream::AlignLeft) onstream and returnsstream.
See alsoright(),center(), andQTextStream manipulators.
CallsQTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::UppercaseBase) onstream and returnsstream.
See alsouppercasebase(),lowercasedigits(), andQTextStream manipulators.
CallsQTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::UppercaseDigits) onstream and returnsstream.
See alsouppercasedigits(),lowercasebase(), andQTextStream manipulators.
CallsQTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ForcePoint) onstream and returnsstream.
See alsoforcepoint(),noforcesign(),noshowbase(), andQTextStream manipulators.
CallsQTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ForceSign) onstream and returnsstream.
See alsoforcesign(),noforcepoint(),noshowbase(), andQTextStream manipulators.
CallsQTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ShowBase) onstream and returnsstream.
See alsoshowbase(),noforcesign(),noforcepoint(), andQTextStream manipulators.
CallsQTextStream::setIntegerBase(8) onstream and returnsstream.
See alsobin(),dec(),hex(), andQTextStream manipulators.
Equivalent toQTextStream::setFieldWidth(width).
Equivalent toQTextStream::setPadChar(ch).
Equivalent toQTextStream::setRealNumberPrecision(precision).
Calls QTextStream::reset() onstream and returnsstream.
See alsoflush() andQTextStream manipulators.
CallsQTextStream::setFieldAlignment(QTextStream::AlignRight) onstream and returnsstream.
See alsoleft(),center(), andQTextStream manipulators.
CallsQTextStream::setRealNumberNotation(QTextStream::ScientificNotation) onstream and returnsstream.
See alsofixed() andQTextStream manipulators.
CallsQTextStream::setNumberFlags(QTextStream::numberFlags() |QTextStream::ShowBase) onstream and returnsstream.
See alsonoshowbase(),forcesign(),forcepoint(), andQTextStream manipulators.
CallsQTextStream::setNumberFlags(QTextStream::numberFlags() |QTextStream::UppercaseBase) onstream and returnsstream.
See alsolowercasebase(),uppercasedigits(), andQTextStream manipulators.
CallsQTextStream::setNumberFlags(QTextStream::numberFlags() |QTextStream::UppercaseDigits) onstream and returnsstream.
See alsolowercasedigits(),uppercasebase(), andQTextStream manipulators.
Calls skipWhiteSpace() onstream and returnsstream.
See alsoQTextStream manipulators.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.