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

📄 qfile.3qt

📁 Trolltech公司发布的基于C++图形开发环境
💻 3QT
📖 第 1 页 / 共 2 页
字号:
'\" t.TH QFile 3qt "24 January 2005" "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 NAMEQFile \- I/O device that operates on files.br.PP\fC#include <qfile.h>\fR.PPInherits QIODevice..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQFile\fR () ".br.ti -1c.BI "\fBQFile\fR ( const QString & name ) ".br.ti -1c.BI "\fB~QFile\fR () ".br.ti -1c.BI "QString \fBname\fR () const".br.ti -1c.BI "void \fBsetName\fR ( const QString & name ) ".br.ti -1c.BI "typedef \fBQCString\fR ( * EncoderFn )( const QString & " "fileName" ") ".br.ti -1c.BI "typedef \fBQString\fR ( * DecoderFn )( const QCString & " "localfileName" ") ".br.ti -1c.BI "bool \fBexists\fR () const".br.ti -1c.BI "bool \fBremove\fR () ".br.ti -1c.BI "virtual bool \fBopen\fR ( int ) ".br.ti -1c.BI "bool \fBopen\fR ( int, FILE * ) ".br.ti -1c.BI "bool \fBopen\fR ( int, int ) ".br.ti -1c.BI "virtual void \fBclose\fR () ".br.ti -1c.BI "virtual void \fBflush\fR () ".br.ti -1c.BI "virtual uint \fBsize\fR () const".br.ti -1c.BI "virtual int \fBat\fR () const".br.ti -1c.BI "virtual bool \fBat\fR ( int ) ".br.ti -1c.BI "virtual bool \fBatEnd\fR () const".br.ti -1c.BI "virtual int \fBreadBlock\fR ( char * " "data" ", uint len ) ".br.ti -1c.BI "virtual int \fBreadLine\fR ( char * " "data" ", uint maxlen ) ".br.ti -1c.BI "int \fBreadLine\fR ( QString &, uint maxlen ) ".br.ti -1c.BI "virtual int \fBgetch\fR () ".br.ti -1c.BI "virtual int \fBputch\fR ( int ) ".br.ti -1c.BI "virtual int \fBungetch\fR ( int ) ".br.ti -1c.BI "int \fBhandle\fR () const".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "QCString \fBencodeName\fR ( const QString & fileName ) ".br.ti -1c.BI "QString \fBdecodeName\fR ( const QCString & localFileName ) ".br.ti -1c.BI "void \fBsetEncodingFunction\fR ( EncoderFn ) ".br.ti -1c.BI "void \fBsetDecodingFunction\fR ( DecoderFn ) ".br.ti -1c.BI "bool \fBexists\fR ( const QString & fileName ) ".br.ti -1c.BI "bool \fBremove\fR ( const QString & fileName ) ".br.in -1c.SH DESCRIPTIONThe QFile class is an I/O device that operates on files..PPQFile is an I/O device for reading and writing binary and text files. A QFile may be used by itself (readBlock and writeBlock) or by more conveniently using QDataStream or QTextStream..PPHere is a code fragment that uses QTextStream to read a text file line by line. It prints each line with a line number..PP.nf.br    QFile f("file.txt");.br    if ( f.open(IO_ReadOnly) ) {    // file opened successfully.br        QTextStream t( &f );        // use a text stream.br        QString s;.br        int n = 1;.br        while ( !t.eof() ) {        // until end of file....br            s = t.readLine();       // line of text excluding '\\n'.br            printf( "%3d: %s\\n", n++, (const char *)s );.br        }.br        f.close();.br    }.fi.PPThe QFileInfo class holds detailed information about a file, such as access permissions, file dates and file types..PPThe QDir class manages directories and lists of file names..PPSee also QDataStream and QTextStream..PPExamples:.(lxml/tagreader/tagreader.cpp xml/tagreader.)l-with-features/tagreader.cpp.SH MEMBER FUNCTION DOCUMENTATION.SH "QFile::QFile ()"Constructs a QFile with no name..SH "QFile::QFile ( const QString & name )"Constructs a QFile with a file name \fIname.\fR.PPSee also setName()..SH "QFile::~QFile ()"Destructs a QFile. Calls close()..SH "bool QFile::at ( int pos ) \fC[virtual]\fR"Sets the file index to \fIpos.\fR Returns TRUE if successful, otherwise FALSE..PPExample:.PP.nf.br    QFile f( "data.bin" );.br    f.open( IO_ReadOnly );                      // index set to 0.br    f.at( 100 );                                // set index to 100.br    f.at( f.at()+50 );                          // set index to 150.br    f.at( f.size()-80 );                        // set index to 80 before EOF.br    f.close();.fi.PP\fBWarning:\fR The result is undefined if the file was opened using the \fCIO_Append\fR specifier..PPSee also size() and open()..PPReimplemented from QIODevice..SH "int QFile::at () const \fC[virtual]\fR"Returns the file index..PPSee also size()..PPReimplemented from QIODevice..SH "bool QFile::atEnd () const \fC[virtual]\fR"Returns TRUE if the end of file has been reached, otherwise FALSE..PPSee also size()..PPReimplemented from QIODevice..SH "void QFile::close () \fC[virtual]\fR"Closes an open file..PPThe file is not closed if it was opened with an existing file handle. If the existing file handle is a \fCFILE*,\fR the file is flushed. If the existing file handle is an \fCint\fR file descriptor, nothing is done to the file..PPSome "write-behind" filesystems may report an unspecified error on closing the file. These errors only indicate that something may have gone wrong since the previous open(). In such a case status() reports IO_UnspecifiedError after close(), otherwise IO_Ok..PPSee also open() and flush()..PPReimplemented from QIODevice..SH "QString QFile::decodeName ( const QCString & localFileName ) \fC[static]\fR"This does the reverse of QFile::encodeName()..PPSee also setDecodingFunction()..SH "QCString QFile::encodeName ( const QString & fileName ) \fC[static]\fR"When you use QFile, QFileInfo, and QDir to access the filesystem with Qt, you can use Unicode filenames. On Unix, these filenames are converted to an 8-bit encoding. If you want to do your own file I/O on Unix, you should convert the filename using this function. On Windows NT, Unicode filenames are supported directly in the filesystem and this function should be avoided. On Windows 95, non-Latin1 locales are not supported at this time..PPBy default, this function converts to the local 8-bit encoding determined by the user's locale. This is sufficient for filenames that the user chooses. Filenames hard-coded into the application should only use 7-bit ASCII filename characters..PPThe conversion scheme can be changed using setEncodingFunction(). This might be useful if you wish to give the user an option to store in filenames in UTF-8, etc., but beware that such filenames would probably then be unrecognizable when seen by other programs..PPSee also decodeName()..SH "bool QFile::exists () const"Returns TRUE if this file exists, otherwise FALSE..PPSee also name()..SH "bool QFile::exists ( const QString & fileName ) \fC[static]\fR"Returns TRUE if the file given by \fIfileName\fR exists, otherwise FALSE..SH "void QFile::flush () \fC[virtual]\fR"Flushes the file buffer to the disk.

⌨️ 快捷键说明

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