Jump to content

Translations:Development/Tutorials/Saving and loading/32/pt-br: Difference between revisions

From KDE TechBase
Juliano Assis (talk | contribs)
Created page with "Agora que temos nosso <tt>QByteArray</tt>, usamos o para gravar no arquivo com <tt>QSaveFile::write()</tt>. Se estivéssemos usando um <tt>QFile</tt> normal, isso faria as alt..."
 
(No difference)

Latest revision as of 19:01, 19 November 2019

Information about message (contribute)
This message has no documentation. If you know where or how this message is used, you can help other translators by adding documentation to this message.
Message definition (Development/Tutorials/Saving and loading)
Now that we have our <tt>QByteArray</tt>, we use it to write to the file with <tt>QSaveFile::write()</tt>. If we were using a normal <tt>QFile</tt>, this would make the changes immediately. However, if a problem occurred partway through writing, the file would become corrupted. For this reason, <tt>QSaveFile</tt> works by first writing to a temporary file and then, when you call <tt>QSaveFile::commit()</tt> the changes are made to the actual file. <tt>commit()</tt> also closes the file.

Agora que temos nosso QByteArray, usamos o para gravar no arquivo com QSaveFile::write(). Se estivéssemos usando um QFile normal, isso faria as alterações imediatamente. No entanto, se um problema ocorresse parcialmente durante a gravação, o arquivo seria corrompido. Por esse motivo, QSaveFile funciona primeiro escrevendo em um arquivo temporário e, em seguida, quando você chama QSaveFile::commit() as alterações são feitas no arquivo real. commit() também fecha o arquivo.