#includeint main() { QFile file("test.txt"); if (file.exists()) qDebug() << "File exists"; else qDebug() << "File does not exist"; return 0; }
#includeIn this example, the code checks if each file in the `files` list exists. The `exists` method is called on each file, and the result is printed to the console. Package library: Qt Core Libraryint main() { QStringList files = { "test1.txt", "test2.txt", "test3.txt" }; for (auto &file : files) { if (QFile::exists(file)) qDebug() << file << "exists"; else qDebug() << file << "does not exist"; } return 0; }