#includeint main() { QFile file("old_name.txt"); file.open(QIODevice::WriteOnly | QIODevice::Text); file.close(); file.setName("new_name.txt"); return 0; }
#includeIn this example, the QFile::rename() static function is used to change the name of the file "old_name.txt" to "new_name.txt". Package library: Qt Coreint main() { QFile::rename("old_name.txt", "new_name.txt"); return 0; }