Thanks that's exactly what I was looking for.
I know setOption() and I'm using it to get (not by mistake but on purpose) Qt dialogs.
Doc about selectFile() didn't specify that this will populate lineedit so I skipped that function... eh.
Thanks that's exactly what I was looking for.
I know setOption() and I'm using it to get (not by mistake but on purpose) Qt dialogs.
Doc about selectFile() didn't specify that this will populate lineedit so I skipped that function... eh.
In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
The advance of computerization however, has not yet wiped out nations and ethnic groups.
hello everyone
why getSaveFileName don't set default save filename like UUID? it's empty
Qt Code:
QString strSaveFile =QFileDialog::getSaveFileName(0, "save", "./44aa756f-6c62-443d-a606-b758fde7e851.txt", "All Files(*.*)", 0, 0);To copy to clipboard, switch view to plain text mode
Because you are using the method incorrectly. The third argument is the initial directory, not the default file name. There is no way to specify the default file name using the QFileDialog static methods; if you want that, you must use the mechanism described in Chris's original answer in this thread.why getSaveFileName don't set default save filename like UUID? it's empty
sorry, i can't show detail.
Qt version: Qt 5.5.1 MinGW 32bit
OS: win7 64bit
in qt5.5.1 assistant,
http://doc.qt.io/qt-4.8/
QString QFileDialog::getSaveFileName(QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0)
This is a convenience static function that will return a file name selected by the user. The file does not have to exist.
It creates a modal file dialog with the given parent widget. If parent is not 0, the dialog will be shown centered over the parent widget.
The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. Only files that match the filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. Multiple filters are separated with ';;'. For instance:
The options argument holds various options about how to run the dialog, see the QFileDialog::Option enum for more information on the flags you can pass.
The default filter can be chosen by setting selectedFilter to the desired value.
The dialog's caption is set to caption. If caption is not specified, a default caption will be used.
On Windows, and OS X, this static function will use the native file dialog and not a QFileDialog.
On Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if parent is not 0 then it will position the dialog just below the parent's title bar. On OS X, with its native file dialog, the filter argument is ignored.
On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If options includes DontResolveSymlinks the file dialog will treat symlinks as regular directories.
Warning: Do not delete parent during the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the QFileDialog constructors.
so, i test for this
the default name exists.Qt Code:
To copy to clipboard, switch view to plain text mode
but
the default name is empty, same as all like UUID's fileName;Qt Code:
QString fileName = QFileDialog::getSaveFileName(0, "Save File","./D99882DA-893E-4054-9344-FBF29E774780.txt","*.*", 0, 0);To copy to clipboard, switch view to plain text mode
so why ? thanks.
Sorry, I did not see the part in the docs about using a file name as part of the dir string. My mistake.the default name is empty, same as all like UUID's fileName; so why ? thanks.
One other thing that it wrong is the way your specify the filter string. The filter should be something like "All files (*.*)". Maybe the file dialog is unable to parse the "*.*" string you are giving it.
Otherwise, I do not know why there is a problem with using a GUID as the default filename.
voidbroken (26th February 2016)
so, i find the reason
QQ截图20160226173506.jpg
thinking....
https://bugreports.qt.io/browse/QTBUG-33962
https://bugreports.qt.io/browse/QTBUG-51373
Last edited by voidbroken; 26th February 2016 at 11:09.
i commited the bug : https://bugreports.qt.io/browse/QTBUG-51373
Bookmarks