Once you know the path to a file (for example, using QDir::entryList(), QFileDialog::getOpenFileName(), or some external source), you can pass it to QFile to receive an object that acts as a handle to the file. Before the file contents can be accessed, the file needs to be opened using the open() method. The basic variant of this method takes a mode in which we need to open the file. The following table explains the modes that are available:
Mode | Description |
ReadOnly |
This file can be read from. |
WriteOnly |
This file can be written to. |
ReadWrite |
This file can be read from and written to. |
Append |
All data writes will be written at the end of the file. |
Truncate |
If the file is present, its ... |