Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11.1
-
None
-
Ubuntu 18.04.3 LTS 64-bit
Gnome 3.28.2
Qt 5.11.1
Description
When selecting a file to open or save, we can pass a filter string to the static functions mentioned in the subject line. The expected behavior is to retain the extension/s in the human-readable part of the filter name, i.e. the user should be able to see what the extension is, for example "Text files (*.txt)" and not just "Text files".
However, the extension is hidden from the user on Linux Ubuntu using the default file navigator.
Here is a small illustration:
#include <QMainWindow> #include <QApplication> #include <QPushButton> #include <QtCore> #include <QFileDialog> #include <QMessageBox> int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow w; QPushButton b; b.setText("Bye!"); w.setCentralWidget(&b); w.connect(&b, &QPushButton::clicked, &w, &QMainWindow::close); QString fn = QFileDialog::getOpenFileName( &w, "Testing the native dialog", QString(), "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"); if (!fn.isEmpty()) { QString msg = "You chose the file:\n"; QMessageBox::information(&w,"File Selected",msg.append(fn)); } fn = QFileDialog::getOpenFileName( &w, "Testing the Qt (non-native) dialog", QString(), "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)", nullptr, QFileDialog::DontUseNativeDialog); if (!fn.isEmpty()) { QString msg = "You chose the file:\n"; QMessageBox::information(&w,"File Selected",msg.append(fn)); } w.show(); return a.exec(); }