QFileDialog::getSaveFileName() return file name without extension [Linux, Ubuntu, x64, Qt 5.2.1]
-
Code example:
@
QString supported_formats = "Joint Photographic Experts Group (.jpg);;Joint Photographic Experts Group (.jpeg);;Portable Network Graphics (.png);;Windows Bitmap (.bmp);;Portable Bitmap (.pbm);;Portable Graymap (.pgm);;Portable Pixmap (.ppm);;X11 Bitmap (.xbm);;X11 Pixmap (.xpm);;Tagged Image File Format (.tif);;Tagged Image File Format (.tiff);;Wireless Application Protocol Bitmap Format (.wbmp)";QString fileName = QFileDialog::getSaveFileName(this, tr("Export Image"), "", supported_formats, 0, 0);
@ -
Hi,
You should also add which version of Qt you are using
-
hm, when Qt uses any gtk theme then it loads (uses) native gtk2 file dialog (GtkFileChooser), so I'm just wondering what Qt have with extension in this case.When you save your filename you should add extension to that file manually, especially in case when you have dozen of extensions in one filter - how Qt can decide which one it should have (if you didn't type any into FileName QLineEdit).
Problem is that extension change in native dialog does not trigger any signal, so you don't know what extension should be before closing GtkFileChooser. Use non-native (non static) stuff if you want more control over Open/Save dialogs.