FileDialog save file default name
-
Hi,
how to preset file name in qml save file dialog (I want to set some default file name in the dialog)?Thanks
-
It's not possible. Even worse, if you reuse the FileDialog, it will default to the last file selected even if this is not what you want. This is one of many bugs and missing features why I think that QtQuick Controls are simply not ready for production use.
There is no simple workaround but if you are willing to add custom C++ code to your QML project, have a look at Advanced FileDialog in QML, which presents a solution that works on Windows, Mac and Gnome.
-
@MartinD Set the
folder
property of FileDialog to the url of the target folder with the preset file name.e.g
file:/tmp/filename.txt
-
Doesn't appear to be working on windows with Qt 5.15.2?
-
I used qt labs platform. YMMV:
import Qt.labs.platform 1.1 as QLP ... QLP.FileDialog { id: filedialog currentFile: "file:///home/user/test2.txt" }