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

📄 qfile.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
📖 第 1 页 / 共 2 页
字号:
.SH "void QFile::flush ()\fC [virtual]\fR"Flushes the file buffer to the disk..PPclose() also flushes the file buffer..PPReimplemented from QIODevice..SH "int QFile::getch ()\fC [virtual]\fR"Reads a single byte/character from the file..PPReturns the byte/character read, or -1 if the end of the file has been reached..PPSee also putch() and ungetch()..PPReimplemented from QIODevice..SH "int QFile::handle () const"Returns the file handle of the file..PPThis is a small positive integer, suitable for use with C library functions such as fdopen() and fcntl(), as well as with QSocketNotifier..PPIf the file is not open or there is an error, handle() returns -1..PPSee also QSocketNotifier..SH "QString QFile::name () const"Returns the name set by setName()..PPSee also setName() and QFileInfo::fileName()..SH "bool QFile::open ( int m )\fC [virtual]\fR"Opens the file specified by the file name currently set, using the mode \fIm\fR. Returns TRUE if successful, otherwise FALSE..PP.PPThe mode parameter \fIm\fR must be a combination of the following flags: <center>.nf.TSl - l. Flag Meaning IO_Raw Raw (non-buffered) file access. IO_ReadOnly Opens the file in read-only mode. IO_WriteOnly Opens the file in write-only mode. If this flag is used with another flag, e.g. IO_ReadOnly or IO_Raw or IO_Append, the file is \fInot\fR truncated; but if used on its own (or with IO_Truncate), the file is truncated. IO_ReadWrite Opens the file in read/write mode, equivalent to IO_Append Opens the file in append mode. (You must actually use IO_Truncate Truncates the file. IO_Translate.TE.fi</center>.PPThe raw access mode is best when I/O is block-operated using a 4KB block size or greater. Buffered access works better when reading small portions of data at a time..PP\fBWarning:\fR When working with buffered files, data may not be written to the file at once. Call flush() to make sure that the data is really written..PP\fBWarning:\fR If you have a buffered file opened for both reading and writing you must not perform an input operation immediately after an output operation or vice versa. You should always call flush() or a file positioning operation, e.g. at(), between input and output operations, otherwise the buffer may contain garbage..PPIf the file does not exist and IO_WriteOnly or IO_ReadWrite is specified, it is created..PPExample:.PP.nf.br        QFile f1( "/tmp/data.bin" );.br        f1.open( IO_Raw | IO_ReadWrite );.br.br        QFile f2( "readme.txt" );.br        f2.open( IO_ReadOnly | IO_Translate );.br.br        QFile f3( "audit.log" );.br        f3.open( IO_WriteOnly | IO_Append );.br.fi.PPSee also name(), close(), isOpen(), and flush()..PPExamples:.)l action/application.cpp, application/application.cpp, chart/chartform_files.cpp, helpviewer/helpwindow.cpp, qdir/qdir.cpp, qwerty/qwerty.cpp, and xml/outliner/outlinetree.cpp..PPReimplemented from QIODevice..SH "bool QFile::open ( int m, FILE * f )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPOpens a file in the mode \fIm\fR using an existing file handle \fIf\fR. Returns TRUE if successful, otherwise FALSE..PPExample:.PP.nf.br    #include <stdio.h>.br.br    void printError( const char* msg ).br    {.br        QFile f;.br        f.open( IO_WriteOnly, stderr );.br        f.writeBlock( msg, qstrlen(msg) );      // write to stderr.br        f.close();.br    }.br.fi.PPWhen a QFile is opened using this function, close() does not actually close the file, only flushes it..PP\fBWarning:\fR If \fIf\fR is \fCstdin\fR, \fCstdout\fR, \fCstderr\fR, you may not be able to seek. See QIODevice::isSequentialAccess() for more information..PPSee also close()..SH "bool QFile::open ( int m, int f )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPOpens a file in the mode \fIm\fR using an existing file descriptor \fIf\fR. Returns TRUE if successful, otherwise FALSE..PPWhen a QFile is opened using this function, close() does not actually close the file..PPThe QFile that is opened using this function, is automatically set to be in raw mode; this means that the file input/output functions are slow. If you run into performance issues, you should try to use one of the other open functions..PP\fBWarning:\fR If \fIf\fR is one of 0 (stdin), 1 (stdout) or 2 (stderr), you may not be able to seek. size() is set to \fCINT_MAX\fR (in limits.h)..PPSee also close()..SH "int QFile::putch ( int ch )\fC [virtual]\fR"Writes the character \fIch\fR to the file..PPReturns \fIch\fR, or -1 if some error occurred..PPSee also getch() and ungetch()..PPReimplemented from QIODevice..SH "QByteArray QIODevice::readAll ()\fC [virtual]\fR"This convenience function returns all of the remaining data in the device..SH "Q_LONG QFile::readLine ( char * p, Q_ULONG maxlen )\fC [virtual]\fR"Reads a line of text..PPReads bytes from the file into the char* \fIp\fR, until end-of-line or \fImaxlen\fR bytes have been read, whichever occurs first. Returns the number of bytes read, or -1 if there was an error. Any terminating newline is not stripped..PPThis function is only efficient for buffered files. Avoid readLine() for files that have been opened with the IO_Raw flag..PPSee also readBlock() and QTextStream::readLine()..PPReimplemented from QIODevice..SH "Q_LONG QFile::readLine ( QString & s, Q_ULONG maxlen )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReads a line of text..PPReads bytes from the file into string \fIs\fR, until end-of-line or \fImaxlen\fR bytes have been read, whichever occurs first. Returns the number of bytes read, or -1 if there was an error, e.g. end of file. Any terminating newline is not stripped..PPThis function is only efficient for buffered files. Avoid using readLine() for files that have been opened with the IO_Raw flag..PPNote that the string is read as plain Latin1 bytes, not Unicode..PPSee also readBlock() and QTextStream::readLine()..SH "bool QFile::remove ()"Removes the file specified by the file name currently set. Returns TRUE if successful; otherwise returns FALSE..PPThe file is closed before it is removed..SH "bool QFile::remove ( const QString & fileName )\fC [static]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPRemoves the file \fIfileName\fR. Returns TRUE if successful, otherwise FALSE..SH "void QFile::setDecodingFunction ( DecoderFn f )\fC [static]\fR"\fBWarning:\fR This function is \fInot\fR reentrant.</p>.PPSets the function for decoding 8-bit file names to \fIf\fR. The default uses the locale-specific 8-bit encoding..PPSee also encodeName() and decodeName()..SH "void QFile::setEncodingFunction ( EncoderFn f )\fC [static]\fR"\fBWarning:\fR This function is \fInot\fR reentrant.</p>.PPSets the function for encoding Unicode file names to \fIf\fR. The default encodes in the locale-specific 8-bit encoding..PPSee also encodeName()..SH "void QFile::setName ( const QString & name )"Sets the name of the file to \fIname\fR. The name can have no path, a relative path or an absolute absolute path..PPDo not call this function if the file has already been opened..PPIf the file name has no path or a relative path, the path used will be whatever the application's current directory path is \fIat the time of the open()\fR call..PPExample:.PP.nf.br        QFile file;.br        QDir::setCurrent( "/tmp" );.br        file.setName( "readme.txt" );.br        QDir::setCurrent( "/home" );.br        file.open( IO_ReadOnly );      // opens "/home/readme.txt" under Unix.br.fi.PPNote that the directory separator "/" works for all operating systems supported by Qt..PPSee also name(), QFileInfo, and QDir..SH "Offset QFile::size () const\fC [virtual]\fR"Returns the file size..PPSee also at()..PPExample: table/statistics/statistics.cpp..PPReimplemented from QIODevice..SH "int QFile::ungetch ( int ch )\fC [virtual]\fR"Puts the character \fIch\fR back into the file and decrements the index if it is not zero..PPThis function is normally called to "undo" a getch() operation..PPReturns \fIch\fR, or -1 if an error occurred..PPSee also getch() and putch()..PPReimplemented from QIODevice..SH "SEE ALSO".BR http://doc.trolltech.com/qfile.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qfile.3qt) and the Qtversion (3.1.1).

⌨️ 快捷键说明

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