测试代码
QFileInfo info("/home/ubuntu/testbackup/a.doc");
qDebug()<<info.fileName();
qDebug()<<info.filePath();
qDebug()<<info.absoluteFilePath();
qDebug()<<info.absolutePath();
qDebug()<<info.path();
qDebug()<<info.canonicalFilePath();
输出
"a.doc"
"/home/ubuntu/testbackup/a.doc"
"/home/ubuntu/testbackup/a.doc"
"/home/ubuntu/testbackup"
"/home/ubuntu/testbackup"
"/home/ubuntu/testbackup/a.doc"