这是我的插槽:
void MainWindow::writeOnFile(const QString &path)
{
// Get info files :
QFileInfo fileInfo(path);
QString name = fileInfo.fileName();
QString lastModif = fileInfo.lastModified().toString();
QString owner = fileInfo.owner();
QString group = fileInfo.group();
QString lastRead = fileInfo.lastRead().toString();
QString created = fileInfo.created().toString();
// Write on Logs :
QString filename = "C:\\Users\\Sherlock\\Desktop\\logs.txt";
QFile file ( filename );
if ( file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text) )
{
QTextStream stream( &file );
stream << "The file " << name
<< " was first created on " << created
<< ", was last read on " << lastRead
<< " and was last modified on " << lastModif
<< ". The owner is " << owner
<< ". The group is " << group
<< endl;
}
}
这是我的输出:
首先在lun上创建了younes.txt文件。 août1719:40:34 2015, 最后读到了伦。 août1719:40:34 2015最后修改日期 三月août1800:21:51 2015.店主是。该小组是
如您所见,所有者和组不会显示。
我做错了吗?
答案 0 :(得分:1)
在Windows [...]上返回一个空字符串。
因此,记录了{{1}}以这种方式行事。