Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QFile Class Reference

Inheritance diagram for QFile:

QIODevice QObject QTemporaryFile

List of all members.


Detailed Description

The QFile class provides an interface for reading from and writing to files.

QFile is an I/O device for reading and writing text and binary files and {The Qt Resource System}{resources}. A QFile may be used by itself or, more conveniently, with a QTextStream or QDataStream.

The file name is usually passed in the constructor, but it can be set at any time using setFileName(). QFile expects the file separator to be '/' regardless of operating system. The use of other separators (e.g., '\') is not supported.

You can check for a file's existence using exists(), and remove a file using remove(). (More advanced file system related operations are provided by QFileInfo and QDir.)

The file is opened with open(), closed with close(), and flushed with flush(). Data is usually read and written using QDataStream or QTextStream, but you can also call the QIODevice-inherited functions read(), readLine(), readAll(), write(). QFile also inherits getChar(), putChar(), and ungetChar(), which work one character at a time.

The size of the file is returned by size(). You can get the current file position using pos(), or move to a new file position using seek(). If you've reached the end of the file, atEnd() returns true.

Definition at line 64 of file qfile.h.


Public Types

typedef QString(* DecoderFn )(const QByteArray &localfileName)
typedef QByteArray(* EncoderFn )(const QString &fileName)
enum  FileError {
  NoError = 0, ReadError = 1, WriteError = 2, FatalError = 3,
  ResourceError = 4, OpenError = 5, AbortError = 6, TimeOutError = 7,
  UnspecifiedError = 8, RemoveError = 9, RenameError = 10, PositionError = 11,
  ResizeError = 12, PermissionsError = 13, CopyError = 14
}
enum  MemoryMapFlags { NoOptions = 0 }
enum  OpenModeFlag {
  NotOpen = 0x0000, ReadOnly = 0x0001, WriteOnly = 0x0002, ReadWrite = ReadOnly | WriteOnly,
  Append = 0x0004, Truncate = 0x0008, Text = 0x0010, Unbuffered = 0x0020
}
enum  Permission {
  ReadOwner = 0x4000, WriteOwner = 0x2000, ExeOwner = 0x1000, ReadUser = 0x0400,
  WriteUser = 0x0200, ExeUser = 0x0100, ReadGroup = 0x0040, WriteGroup = 0x0020,
  ExeGroup = 0x0010, ReadOther = 0x0004, WriteOther = 0x0002, ExeOther = 0x0001
}

Public Slots

void deleteLater ()

Signals

void aboutToClose ()
void bytesWritten (qint64 bytes)
void destroyed (QObject *=0)
void readChannelFinished ()
void readyRead ()

Public Member Functions

bool atEnd () const
bool blockSignals (bool b)
virtual qint64 bytesAvailable () const
virtual qint64 bytesToWrite () const
virtual bool canReadLine () const
const QObjectListchildren () const
virtual void close ()
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
bool copy (const QString &newName)
bool disconnect (const QObject *receiver, const char *member=0)
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
void dumpObjectInfo ()
void dumpObjectTree ()
QList< QByteArraydynamicPropertyNames () const
FileError error () const
QString errorString () const
virtual bool event (QEvent *)
virtual bool eventFilter (QObject *, QEvent *)
bool exists () const
virtual QAbstractFileEnginefileEngine () const
QString fileName () const
template<typename T>
findChild (const QString &aName=QString()) const
template<typename T>
QList< T > findChildren (const QRegExp &re) const
template<typename T>
QList< T > findChildren (const QString &aName=QString()) const
bool flush ()
bool getChar (char *c)
int handle () const
bool inherits (const char *classname) const
void installEventFilter (QObject *)
bool isOpen () const
bool isReadable () const
bool isSequential () const
bool isTextModeEnabled () const
bool isWidgetType () const
bool isWritable () const
void killTimer (int id)
bool link (const QString &newName)
uchar * map (qint64 offset, qint64 size, MemoryMapFlags flags=NoOptions)
void moveToThread (QThread *thread)
QString objectName () const
bool open (int fd, OpenMode flags)
bool open (FILE *f, OpenMode flags)
bool open (OpenMode flags)
OpenMode openMode () const
QObjectparent () const
QByteArray peek (qint64 maxlen)
qint64 peek (char *data, qint64 maxlen)
Permissions permissions () const
qint64 pos () const
QVariant property (const char *name) const
bool putChar (char c)
 QFile (const QString &name, QObject *parent)
 QFile (QObject *parent)
 QFile (const QString &name)
 QFile ()
QByteArray read (qint64 maxlen)
qint64 read (char *data, qint64 maxlen)
QByteArray readAll ()
QByteArray readLine (qint64 maxlen=0)
qint64 readLine (char *data, qint64 maxlen)
QString readLink () const
bool remove ()
void removeEventFilter (QObject *)
bool rename (const QString &newName)
virtual bool reset ()
bool resize (qint64 sz)
bool seek (qint64 offset)
void setFileName (const QString &name)
void setObjectName (const QString &name)
void setParent (QObject *)
bool setPermissions (Permissions permissionSpec)
bool setProperty (const char *name, const QVariant &value)
void setTextModeEnabled (bool enabled)
void setUserData (uint id, QObjectUserData *data)
bool signalsBlocked () const
qint64 size () const
int startTimer (int interval)
QString symLinkTarget () const
QThreadthread () const
void ungetChar (char c)
bool unmap (uchar *address)
void unsetError ()
QObjectUserData * userData (uint id) const
virtual bool waitForBytesWritten (int msecs)
virtual bool waitForReadyRead (int msecs)
qint64 write (const QByteArray &data)
qint64 write (const char *data, qint64 len)
 ~QFile ()

Static Public Member Functions

static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
static bool copy (const QString &fileName, const QString &newName)
static QString decodeName (const char *localFileName)
static QString decodeName (const QByteArray &localFileName)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static QByteArray encodeName (const QString &fileName)
static bool exists (const QString &fileName)
static bool link (const QString &oldname, const QString &newName)
static Permissions permissions (const QString &filename)
static QString readLink (const QString &fileName)
static uint registerUserData ()
static bool remove (const QString &fileName)
static bool rename (const QString &oldName, const QString &newName)
static bool resize (const QString &filename, qint64 sz)
static void setDecodingFunction (DecoderFn)
static void setEncodingFunction (EncoderFn)
static bool setPermissions (const QString &filename, Permissions permissionSpec)
static QString symLinkTarget (const QString &fileName)

Protected Member Functions

virtual void childEvent (QChildEvent *)
virtual void connectNotify (const char *signal)
virtual void customEvent (QEvent *)
virtual void disconnectNotify (const char *signal)
 QFile (QFilePrivate &dd, QObject *parent=0)
qint64 readData (char *data, qint64 maxlen)
qint64 readLineData (char *data, qint64 maxlen)
int receivers (const char *signal) const
QObjectsender () const
void setErrorString (const QString &errorString)
void setOpenMode (OpenMode openMode)
virtual void timerEvent (QTimerEvent *)
qint64 writeData (const char *data, qint64 len)

Protected Attributes

QObjectData * d_ptr

Static Protected Attributes

static const QMetaObject staticQtMetaObject

Properties

QString objectName
 the name of this object

Friends

class QApplication
class QApplicationPrivate
class QCoreApplication
class QCoreApplicationPrivate
struct QMetaObject
class QThreadData
class QWidget

Related Functions

(Note that these are not member functions.)

qFindChild (const QObject *obj, const QString &name=QString(), T dummy=0)
qFindChild (const QObject *obj, const QString &name)
QList< T > qFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
QList< T > qFindChildren (const QObject *obj, const QString &name)
T * qobject_cast (QObject *object)
 QObjectList
void * qt_find_obj_child (QObject *parent, const char *type, const QString &name)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index