Default file name for QFileDialog
-
Hello, is it possible to set a default file name for QFileDialog::getSaveFileName? So when the user click in the button to save the file it will come with a default name that is changeable.
@Marcusdrl
Try as per the example at https://doc.qt.io/qt-5/qfiledialog.html#getSaveFileNameThe file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected
But I don't know if that indeed only works if the file already exists and so can be selected.
-
From documentation:
This is a convenience static function that will return a file name selected by the user. The file does not have to exist.@Gerd
That only talks about whether the file to save to has to exist, or can be a new one. It does not say anything about whether if you supply a file path for thedir
parameter which does not exist it will or will not copy the filename into the edit control for the user. Which is why I said the OP will need to test whether it does or not. -
@Marcusdrl
Try as per the example at https://doc.qt.io/qt-5/qfiledialog.html#getSaveFileNameThe file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected
But I don't know if that indeed only works if the file already exists and so can be selected.