Default file name for QFileDialog
-
wrote on 22 Jun 2021, 14:04 last edited by
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.
-
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.
wrote on 22 Jun 2021, 14:26 last edited by@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.
-
wrote on 22 Jun 2021, 14:31 last edited by
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. -
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.wrote on 22 Jun 2021, 15:09 last edited by JonB@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.
wrote on 22 Jun 2021, 16:12 last edited by
4/5