⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qtextstream.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 2 页
字号:
'\" t.TH QTextStream 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQTextStream \- Basic functions for reading and writing text using a QIODevice.PP\fC#include <qtextstream.h>\fR.PPInherited by QTextIStream and QTextOStream..PP.SS "Public Members".in +1c.ti -1c.BI "enum \fBEncoding\fR { Locale, Latin1, Unicode, UnicodeNetworkOrder, UnicodeReverse, RawUnicode, UnicodeUTF8 }".br.ti -1c.BI "void \fBsetEncoding\fR ( Encoding e )".br.ti -1c.BI "void \fBsetCodec\fR ( QTextCodec * codec )".br.ti -1c.BI "\fBQTextStream\fR ()".br.ti -1c.BI "\fBQTextStream\fR ( QIODevice * iod )".br.ti -1c.BI "\fBQTextStream\fR ( QString * str, int filemode )".br.ti -1c.BI "QTextStream ( QString & str, int filemode )  \fI(obsolete)\fR".br.ti -1c.BI "\fBQTextStream\fR ( QByteArray a, int mode )".br.ti -1c.BI "\fBQTextStream\fR ( FILE * fh, int mode )".br.ti -1c.BI "virtual \fB~QTextStream\fR ()".br.ti -1c.BI "QIODevice * \fBdevice\fR () const".br.ti -1c.BI "void \fBsetDevice\fR ( QIODevice * iod )".br.ti -1c.BI "void \fBunsetDevice\fR ()".br.ti -1c.BI "bool \fBatEnd\fR () const".br.ti -1c.BI "bool eof () const  \fI(obsolete)\fR".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( QChar & c )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( char & c )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( signed short & i )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( unsigned short & i )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( signed int & i )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( unsigned int & i )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( signed long & i )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( unsigned long & i )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( float & f )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( double & f )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( char * s )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( QString & str )".br.ti -1c.BI "QTextStream & \fBoperator>>\fR ( QCString & str )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( QChar c )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( char c )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( signed short i )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( unsigned short i )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( signed int i )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( unsigned int i )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( signed long i )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( unsigned long i )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( float f )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( double f )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( const char * s )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( const QString & s )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( const QCString & s )".br.ti -1c.BI "QTextStream & \fBoperator<<\fR ( void * ptr )".br.ti -1c.BI "QTextStream & \fBreadRawBytes\fR ( char * s, uint len )".br.ti -1c.BI "QTextStream & \fBwriteRawBytes\fR ( const char * s, uint len )".br.ti -1c.BI "QString \fBreadLine\fR ()".br.ti -1c.BI "QString \fBread\fR ()".br.ti -1c.BI "void \fBskipWhiteSpace\fR ()".br.ti -1c.BI "int \fBflags\fR () const".br.ti -1c.BI "int \fBflags\fR ( int f )".br.ti -1c.BI "int \fBsetf\fR ( int bits )".br.ti -1c.BI "int \fBsetf\fR ( int bits, int mask )".br.ti -1c.BI "int \fBunsetf\fR ( int bits )".br.ti -1c.BI "void \fBreset\fR ()".br.ti -1c.BI "int \fBwidth\fR () const".br.ti -1c.BI "int \fBwidth\fR ( int w )".br.ti -1c.BI "int \fBfill\fR () const".br.ti -1c.BI "int \fBfill\fR ( int f )".br.ti -1c.BI "int \fBprecision\fR () const".br.ti -1c.BI "int \fBprecision\fR ( int p )".br.in -1c.SH DESCRIPTIONThe QTextStream class provides basic functions for reading and writing text using a QIODevice..PPThe text stream class has a functional interface that is very similar to that of the standard C++ iostream class. The difference between iostream and QTextStream is that our stream operates on a QIODevice which is easily subclassed, whereas iostream operates on FILE * pointers which cannot be subclassed..PPQt provides several global functions similar to the ones in iostream:.TPbin sets the QTextStream to read/write binary numbers.TPoct sets the QTextStream to read/write octal numbers.TPdec sets the QTextStream to read/write decimal numbers.TPhex sets the QTextStream to read/write hexadecimal numbers.TPendl forces a line break.TPflush forces the QIODevice to flush any buffered data.TPws eats any available whitespace (on input).TPreset resets the QTextStream to its default mode (see reset()).TPqSetW(int) sets the field width as specified with the argument.TPqSetFill(int) sets the fill character as specified with the argument.TPqSetPrecision(int) sets the precision as specified with the argument.PP\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..PPThe QTextStream class reads and writes text; it is not appropriate for dealing with binary data (but QDataStream is)..PPBy default, output of Unicode text (i.e. QString) 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..PPThe QIODevice 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..PPSee also QDataStream, Input/Output and Networking and Text Related Classes..SS "Member Type Documentation".SH "QTextStream::Encoding".TP\fCQTextStream::Locale\fR.TP\fCQTextStream::Latin1\fR.TP\fCQTextStream::Unicode\fR.TP\fCQTextStream::UnicodeNetworkOrder\fR.TP\fCQTextStream::UnicodeReverse\fR.TP\fCQTextStream::RawUnicode\fR.TP\fCQTextStream::UnicodeUTF8\fR.PP.SH MEMBER FUNCTION DOCUMENTATION.SH "QTextStream::QTextStream ()"Constructs a data stream that has no IO device..SH "QTextStream::QTextStream ( QIODevice * iod )"Constructs a text stream that uses the IO device \fIiod\fR..SH "QTextStream::QTextStream ( QString * str, int filemode )"Constructs a text stream that operates on the Unicode QString, \fIstr\fR, through an internal device. The \fIfilemode\fR argument is passed to the device's open() function; see QIODevice::mode()..PPIf you set an encoding or codec with setEncoding() or setCodec(), this setting is ignored for text streams that operate on QString..PPExample:.PP.nf.br    QString str;.br    QTextStream ts( &str, IO_WriteOnly );.br    ts << "pi = " << 3.14; // str == "pi = 3.14".br.fi.PPWriting 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:.PP.nf.br    QString str = "pi = 3.14";.br    QTextStream ts( &str, IO_WriteOnly );.br    ts <<  "2+2 = " << 2+2; // str == "2+2 = 414".br.fi.PPNote that because QString is Unicode, you should not use readRawBytes() or writeRawBytes() on such a stream..SH "QTextStream::QTextStream ( QString & str, int filemode )"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPThis constructor is equivalent to the constructor taking a QString* parameter..SH "QTextStream::QTextStream ( QByteArray a, int mode )"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 QIODevice::mode()..PPExample:.PP.nf.br    QByteArray array;.br    QTextStream ts( array, IO_WriteOnly );.br    ts << "pi = " << 3.14 << '\\0'; // array == "pi = 3.14".br.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();.br.fi.SH "QTextStream::QTextStream ( FILE * fh, int 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 QIODevice::mode()..PPNote 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..SH "QTextStream::~QTextStream ()\fC [virtual]\fR"Destroys the text stream..PP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -