Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileDialog File Filter
QtWS25 Last Chance

QFileDialog File Filter

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rondog
    wrote on last edited by
    #1

    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.

    Test Code:

    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).

    raven-worxR 1 Reply Last reply
    0
    • R Rondog

      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.

      Test Code:

      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).

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @Rondog
      this doesn't happen using Qt 5.6-msvc2015
      Have you looked for a bug report? If not, can you create one.
      Unfortunately it seems Qt 5.6 and 5.7 are still very buggy :/

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rondog
        wrote on last edited by Rondog
        #3

        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).

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved