![]() The following example reads a text file line by line: QFile file("in.txt") If you've reached the end of the file, atEnd() returns true. You can get the current file position using pos(), or move to a new file position using seek(). The size of the file is returned by size(). QFile also inherits getChar(), putChar(), and ungetChar(), which work one character at a time. ![]() Data is usually read and written using QDataStream or QTextStream, but you can also call the QIODevice-inherited functions read(), readLine(), readAll(), write(). The file is opened with open(), closed with close(), and flushed with flush(). (More advanced file system related operations are provided by QFileInfo and QDir.) You can check for a file's existence using exists(), and remove a file using remove(). The use of other separators (e.g., '\') is not supported. QFile expects the file separator to be '/' regardless of operating system. The file name is usually passed in the constructor, but it can be set at any time using setFileName(). A QFile may be used by itself or, more conveniently, with a QTextStream or QDataStream. QFile is an I/O device for reading and writing text and binary files and resources. The QFile class provides an interface for reading from and writing to files. 9 protected functions inherited from QObject.5 protected functions inherited from QIODevice.3 protected functions inherited from QFileDevice.10 static public members inherited from QObject.SetPermissions(const QString & fileName, QFileDevice::Permissions permissions) Resize(const QString & fileName, qint64 sz) Rename(const QString & oldName, const QString & newName) Link(const QString & fileName, const QString & linkName) 32 public functions inherited from QObjectĬopy(const QString & fileName, const QString & newName)ĭecodeName(const QByteArray & localFileName). ![]() 44 public functions inherited from QIODevice.18 public functions inherited from QFileDevice.SetPermissions(QFileDevice::Permissions permissions) override Open(int fd, QIODevice::OpenMode mode, QFileDevice::FileHandleFlags handleFlags = DontCloseHandle) Open(FILE * fh, QIODevice::OpenMode mode, QFileDevice::FileHandleFlags handleFlags = DontCloseHandle) QFile(const QString & name, QObject * parent) ![]() Note: All functions in this class are reentrant. List of all members, including inherited members. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |