Qfiledialog: selecting the wrong type of file
-
@emeka_o said in Qfiledialog: selecting the wrong type of file:
How do I handle this error.
You have the filename so you know it's extension. But since an extension does not tell you anything about the real content of a file you should fix your program so it does not crash even the csv file does not contain the expected content.
-
I want to open .csv files only and I have been successful doing this.
However if another type of file is opened (.txt or excel) the program crashes.
How do I handle this error. If the user selects a wrong type of file.@emeka_o said in Qfiledialog: selecting the wrong type of file:
.csv files only
You could add a filter to show csv files only.
Your program will still crash, when some other file types are opened but it's not possible to select something else than csv files.
-
@emeka_o said in Qfiledialog: selecting the wrong type of file:
.csv files only
You could add a filter to show csv files only.
Your program will still crash, when some other file types are opened but it's not possible to select something else than csv files.
-
dialog.setNameFilter(tr("Images (*.png *.xpm *.jpg)"));In the above example, the filter is set to "Images (*.png *.xpm *.jpg)", this means that only files with the extension png, xpm, or jpg will be shown in the QFileDialog.