Hello,
my app wasn't able to create an empty file due, for example, to insufficient permissions: shall I call file.close() anyway?
No you're not required to.
my app was able to create an empty file: shall I call file.close()
Again, you're not required to. You can call it if you wish, but by default the QFile instance will close the file when it goes out of scope. Moreover calling close() on an unopened file is permitted, but it does nothing.
The I want to add some text to the file, but I do not want to interact with it here: I pass the file name to a function which is taking care of it.
Don't reopen the file on each write, it's a somewhat heavy operation. Have a member variable, open it once and write as much as you'd like.
Now, because of all the previous checks, I shouldn't have to check if file exists or if I can open it, right?
Wrong. No one is guaranteeing you that the file exists. On windows a file will (usually) be locked when opened, but on Linux the user can delete it even while you're writing onto it. So don't skip the checks. Also as I mentioned above, don't reopen the file on each write.
Kind regards.