<?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[File saving problem]]></title><description><![CDATA[<p dir="auto">Hi everyone</p>
<p dir="auto">I was trying to improve the <a href="https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/quickcontrols/texteditor?h=6.5" target="_blank" rel="noopener noreferrer nofollow ugc">Project qt </a><br />
<img src="https://doc.qt.io/qt-6/images/qtquickcontrols-texteditor-desktop.jpg" alt="alt text" class=" img-fluid img-markdown" /></p>
<p dir="auto">The problem is that at the time of saving the file<br />
the file path is lost once saved you can't do it a second time</p>
<pre><code>function savefunc()
        {
            if(document.fileName === ("untitled.txt"))
              {
               saveDialog.open()
            }
            else
               {
                console.log(document.fileName)
                document.save(document.fileName)
            }
        }
</code></pre>
<p dir="auto">I check that filename is untitled.txt which is by default write<br />
so if it's yes save dialog.open()<br />
otherwise I use the path stored in filename</p>
<p dir="auto">The project is the same as that of<br />
<a href="https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/quickcontrols/texteditor?h=6.5" target="_blank" rel="noopener noreferrer nofollow ugc">https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/quickcontrols/texteditor?h=6.5</a><br />
except that it does not present a recorded function but saves as</p>
]]></description><link>https://forum.qt.io/topic/145702/file-saving-problem</link><generator>RSS for Node</generator><lastBuildDate>Tue, 27 Oct 2026 20:51:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/145702.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 11 Jun 2023 15:55:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to File saving problem on Thu, 22 Jun 2023 00:00:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fortiga">@<bdi>Fortiga</bdi></a> Hi<br />
You have to save the location of the saved file so you can use it at the next time. I changed the saveDialog in textEditor.qml, something like this works:</p>
<pre><code>    property url savedLocation: ""
    FileDialog {
        id: saveDialog
        fileMode: FileDialog.SaveFile
        defaultSuffix: document.fileType
        nameFilters: openDialog.nameFilters
        selectedNameFilter.index: document.fileType === "txt" ? 0 : 1
        currentFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
        onAccepted: {
            console.log("currentFolder:"+currentFolder)
            savedLocation = currentFolder
            document.saveAs(selectedFile)
        }
        onVisibleChanged: {
            if (visible &amp;&amp; savedLocation !== "") {
                currentFolder = savedLocation
            }

        }
    }
</code></pre>
]]></description><link>https://forum.qt.io/post/762287</link><guid isPermaLink="true">https://forum.qt.io/post/762287</guid><dc:creator><![CDATA[johngod]]></dc:creator><pubDate>Thu, 22 Jun 2023 00:00:02 GMT</pubDate></item><item><title><![CDATA[Reply to File saving problem on Thu, 22 Jun 2023 12:46:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/johngod">@<bdi>johngod</bdi></a> Thank you for your reply<br />
in fact it was necessary to replace document.save(fileName) by document.save(FileUrl)</p>
<pre><code>function savefunc()
        {
            if(document.fileName === ("untitled.txt"))
              {
               saveDialog.open()
            }
            else
               {

                document.save(document.fileUrl)
            }
        }
</code></pre>
<p dir="auto">Thank you</p>
]]></description><link>https://forum.qt.io/post/762329</link><guid isPermaLink="true">https://forum.qt.io/post/762329</guid><dc:creator><![CDATA[Fortiga]]></dc:creator><pubDate>Thu, 22 Jun 2023 12:46:33 GMT</pubDate></item><item><title><![CDATA[Reply to File saving problem on Thu, 22 Jun 2023 00:00:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/fortiga">@<bdi>Fortiga</bdi></a> Hi<br />
You have to save the location of the saved file so you can use it at the next time. I changed the saveDialog in textEditor.qml, something like this works:</p>
<pre><code>    property url savedLocation: ""
    FileDialog {
        id: saveDialog
        fileMode: FileDialog.SaveFile
        defaultSuffix: document.fileType
        nameFilters: openDialog.nameFilters
        selectedNameFilter.index: document.fileType === "txt" ? 0 : 1
        currentFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
        onAccepted: {
            console.log("currentFolder:"+currentFolder)
            savedLocation = currentFolder
            document.saveAs(selectedFile)
        }
        onVisibleChanged: {
            if (visible &amp;&amp; savedLocation !== "") {
                currentFolder = savedLocation
            }

        }
    }
</code></pre>
]]></description><link>https://forum.qt.io/post/762287</link><guid isPermaLink="true">https://forum.qt.io/post/762287</guid><dc:creator><![CDATA[johngod]]></dc:creator><pubDate>Thu, 22 Jun 2023 00:00:02 GMT</pubDate></item><item><title><![CDATA[Reply to File saving problem on Wed, 21 Jun 2023 20:30:14 GMT]]></title><description><![CDATA[<p dir="auto">help svp</p>
]]></description><link>https://forum.qt.io/post/762283</link><guid isPermaLink="true">https://forum.qt.io/post/762283</guid><dc:creator><![CDATA[Fortiga]]></dc:creator><pubDate>Wed, 21 Jun 2023 20:30:14 GMT</pubDate></item></channel></rss>