QFile::copy() locks my xlsx file when copying it from app resources to a local directory
Solved
General and Desktop
-
Hi,
I've encouraged a weird behavior ofQFile::copy
when trying to copy an xlsx document from my app's resources into a local folder. The function succeeds but the new document becomes locked and can't be edited. Then I tried to do a "manual" copy, the problem disappeared!// This locks the copied document // QFile::copy(":/Resources/doc/document.xlsx", documentPath); // "manual" copy doesn't! QFile orginalDoc(":/Resources/doc/document.xlsx"); orginalDoc.open(QIODevice::ReadOnly); QFile copyDoc(documentPath); copyDoc.open(QIODevice::WriteOnly); copyDoc.write(orginal.readAll()); copyDoc.close();
So I think there's an issue with
QFile::copy
, or it maybe a silly mistake, any ideas? -
Hi,
Did you check the permissions of the file after the copy happens ?
-
Because it's copied from a read only file system.
-
The resource system is ready-only by design.
You can use QFile::setPermissions to make it writable.