QFile is a class in the Qt library that provides an interface for file I/O operations. The remove() function of the QFile class is used to delete a file from the file system.
Example 1: Remove a file named "example.txt" from the current directory.
```c++ #include
int main() { QFile::remove("example.txt"); return 0; }
Example 2: Remove a file located in a specific path.
Example 3: Remove multiple files located in a directory.
c++
#include
#include
int main() {
QString dirPath = "C:/example/";
QDir dir(dirPath);
QStringList filters;
filters << "*.txt"; // remove all txt files
QStringList files = dir.entryList(filters, QDir::Files);
foreach(QString file, files) {
QString filePath = dirPath + file;
QFile::remove(filePath);
}
return 0;
}
```
These examples use the QFile class from the Qt Core module, which is provided by the Qt library.
C++ (Cpp) QFile::remove - 30 examples found. These are the top rated real world C++ (Cpp) examples of QFile::remove extracted from open source projects. You can rate examples to help us improve the quality of examples.