<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QFile::copy() locks my xlsx file when copying it from app resources to a local directory]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I've encouraged a weird behavior of <code>QFile::copy</code> when trying to copy an <strong>xlsx</strong> document from my app's resources into a local folder. The function <strong>succeeds</strong> but the new document becomes <strong>locked</strong> and can't be edited. Then I tried to do a "<strong>manual</strong>" copy, the problem <strong>disappeared</strong>!</p>
<pre><code>// 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();

</code></pre>
<p dir="auto">So I think there's an issue with <code>QFile::copy</code>, or it maybe a silly mistake, any ideas?</p>
]]></description><link>https://forum.qt.io/topic/135829/qfile-copy-locks-my-xlsx-file-when-copying-it-from-app-resources-to-a-local-directory</link><generator>RSS for Node</generator><lastBuildDate>Tue, 19 May 2026 15:31:05 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/135829.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 14 Apr 2022 18:49:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QFile::copy() locks my xlsx file when copying it from app resources to a local directory on Thu, 14 Apr 2022 19:46:37 GMT]]></title><description><![CDATA[<p dir="auto">Ooh true, silly mistake then.. Thanks <a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a>!</p>
]]></description><link>https://forum.qt.io/post/710498</link><guid isPermaLink="true">https://forum.qt.io/post/710498</guid><dc:creator><![CDATA[SamurayH]]></dc:creator><pubDate>Thu, 14 Apr 2022 19:46:37 GMT</pubDate></item><item><title><![CDATA[Reply to QFile::copy() locks my xlsx file when copying it from app resources to a local directory on Thu, 14 Apr 2022 19:08:38 GMT]]></title><description><![CDATA[<p dir="auto">The resource system is ready-only by design.</p>
<p dir="auto">You can use <a href="https://doc.qt.io/qt-5/qfile.html#setPermissions" target="_blank" rel="noopener noreferrer nofollow ugc">QFile::setPermissions</a> to make it writable.</p>
]]></description><link>https://forum.qt.io/post/710486</link><guid isPermaLink="true">https://forum.qt.io/post/710486</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 14 Apr 2022 19:08:38 GMT</pubDate></item><item><title><![CDATA[Reply to QFile::copy() locks my xlsx file when copying it from app resources to a local directory on Thu, 14 Apr 2022 19:04:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> You mean a resource file becomes read only when the app gets compiled?</p>
]]></description><link>https://forum.qt.io/post/710484</link><guid isPermaLink="true">https://forum.qt.io/post/710484</guid><dc:creator><![CDATA[SamurayH]]></dc:creator><pubDate>Thu, 14 Apr 2022 19:04:57 GMT</pubDate></item><item><title><![CDATA[Reply to QFile::copy() locks my xlsx file when copying it from app resources to a local directory on Thu, 14 Apr 2022 19:02:50 GMT]]></title><description><![CDATA[<p dir="auto">Because it's copied from a read only file system.</p>
]]></description><link>https://forum.qt.io/post/710483</link><guid isPermaLink="true">https://forum.qt.io/post/710483</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 14 Apr 2022 19:02:50 GMT</pubDate></item><item><title><![CDATA[Reply to QFile::copy() locks my xlsx file when copying it from app resources to a local directory on Thu, 14 Apr 2022 19:02:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> I just checked, it has <strong>ReadOnly</strong> permission.. why?</p>
]]></description><link>https://forum.qt.io/post/710482</link><guid isPermaLink="true">https://forum.qt.io/post/710482</guid><dc:creator><![CDATA[SamurayH]]></dc:creator><pubDate>Thu, 14 Apr 2022 19:02:01 GMT</pubDate></item><item><title><![CDATA[Reply to QFile::copy() locks my xlsx file when copying it from app resources to a local directory on Thu, 14 Apr 2022 18:53:48 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Did you check the permissions of the file after the copy happens ?</p>
]]></description><link>https://forum.qt.io/post/710479</link><guid isPermaLink="true">https://forum.qt.io/post/710479</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 14 Apr 2022 18:53:48 GMT</pubDate></item></channel></rss>