QFile file(path); bool ok = file.open(QIODevice::ReadOnly); if (ok)
{ int off = 10; file.seek(file.size() - off); //将当前读取文件指针移动到指定位置 QString str = QString::fromLocal8Bit(file.read(off)); file.close(); ok = file.open(QIODevice::WriteOnly); if (ok) { file.write(str.toUtf8()); file.close(); }
}
file.resize(10); //保留文件前面10个字节的数据