QFileDialog File Filter
Using Qt 5.6.0 with MinGW 4.8.2 on Win XP x86.
I was running some tests today and noticed the file filters are partially case sensitive on Windows. I didn't see this problem on OS X and I didn't bother testing this on GNU/Linux for obvious reasons.
QString filter = “Some File Type (*.dat *.asc *.txt)”; file_name = QFileDialog::getSaveFileName(this, ”Enter Filename to Write”, d_last_file_name, filter);
In the file save dialog that appears when running this code if I enter an upper case version of any file extension other than the first one then the first filter extension is appended to the end of the name I entered.
Example using filter (*.dat *.asc *.txt):
Entered: file_name.txt Returned: file_name.txt Entered: file_name.TXT Returned: file_name.TXT.dat Entered: file_name.asc Returned: file_name.asc Entered: file_name.ASC Returned: file_name.ASC.dat
Is there any way to turn off this feature? I checked the QFileDialog::getSaveFileName() options and didn't see anything related to case sensitive filters.
I haven't noticed this in previous versions of Qt but I don't think I specifically looked for this either (so I might not have noticed it).
I have been looking at the source code for the qwindows platform plugin (qwindowsdialoghelpers.cpp) and found out that the mangled file name is from the return data from the Win32 function GetSaveFileName() so it appears to be from the OS apparently (?).
I have also read that starting with Vista the Win32 functions GetSaveFileName() and GetOpenFileName() are now just wrappers for the new Common Item Dialog.
When I tested this same program on Windows 7 it worked properly. It seems to only be an issue on WinXP (or older perhaps?). I assume @raven-worx tested this on Win7 or higher as well which is why it worked properly.
I noticed a define statement at the top of the qwindows platform plugin that might be part of the problem (?). I am compiling the programs with WinXP because I need to make sure they will run on this OS. Maybe something odd happens from this not being set suitable for WinXP (?).
// top of qwindowsdialoghelpers.cpp #define _WIN32_WINNT 0x0600 from the MSDN - _WIN32_WINNT version constants -------------------------------------------------------- #define _WIN32_WINNT_NT4 0x0400 // Windows NT 4.0 #define _WIN32_WINNT_WIN2K 0x0500 // Windows 2000 #define _WIN32_WINNT_WINXP 0x0501 // Windows XP #define _WIN32_WINNT_WS03 0x0502 // Windows Server 2003 #define _WIN32_WINNT_WIN6 0x0600 // Windows Vista #define _WIN32_WINNT_VISTA 0x0600 // Windows Vista #define _WIN32_WINNT_WS08 0x0600 // Windows Server 2008 #define _WIN32_WINNT_LONGHORN 0x0600 // Windows Vista #define _WIN32_WINNT_WIN7 0x0601 // Windows 7 #define _WIN32_WINNT_WIN8 0x0602 // Windows 8 #define _WIN32_WINNT_WINBLUE 0x0603 // Windows 8.1 #define _WIN32_WINNT_WINTHRESHOLD 0x0A00 // Windows 10 #define _WIN32_WINNT_WIN10 0x0A00 // Windows 10
I am pretty sure the file filter name mangling is not a widespread windows problem. There must be some mismatch somewhere between the program and the core OS. Something odd whatever it is.
I am confident it is not a Qt problem (unless you consider kludges to solve specific OS problems a bug fix).