Results 1 to 8 of 8

Thread: QFileDialog: how to filter files with no extension

  1. #1
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QFileDialog: how to filter files with no extension

    Hi,

    a very quick question,
    I am trying to open/filter files with QFileDialog::getOpenFileName which have no extension. Something like document1, document2, etc
    My code works so far for .txt and All Files


    Qt Code:
    1. QString fileName = QFileDialog::getOpenFileName( this, tr("Open HST xy-list(flux vs wave) file..."), sWDir, tr("HST ASCII File (*.txt);;All files (*.*)"), 0, QFileDialog::DontUseNativeDialog );
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QFileDialog: how to filter files with no extension

    The following code works fine for me in Linux:
    Qt Code:
    1. QString fileName = QFileDialog::getOpenFileName( this, tr("Open HST xy-list(flux vs wave) file..."), sWDir, tr("HST ASCII File (*.txt);;All files (*)"), 0, QFileDialog::DontUseNativeDialog );
    To copy to clipboard, switch view to plain text mode 
    Oleg Shparber

  3. #3
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QFileDialog: how to filter files with no extension

    Qt Code:
    1. All files (*)
    To copy to clipboard, switch view to plain text mode 
    this does not work in windows, it shows simply all files and all extensions. Any ideas?!

  4. #4
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QFileDialog: how to filter files with no extension

    nothing new? regular expression perhaps?

  5. #5
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QFileDialog: how to filter files with no extension

    You can try to reimplement QFileDialog filtering filenames with dots, but standard class cannot do this. Yes, asterisk shows all files without exceptions.
    Oleg Shparber

  6. #6
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QFileDialog: how to filter files with no extension

    do you mean by using reg expression? I haven't seen anything similar so far. I'll give a try, but if you have something to suggest..more than welcome!

  7. #7
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QFileDialog: how to filter files with no extension

    Yes, you can use regexp to filter files. But are you sure you really want to hide all files containing dots? Windows thinks that everything after last dot is extension, but actually it can be simply a part of name, like .htaccess files.
    Oleg Shparber

  8. #8
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QFileDialog: how to filter files with no extension

    believe it or not, I haven't managed to filter filenames with dots.
    Actually as I google I haven't seen any example of QRegExpand QFileDialog.
    This thread appears in google results as the most representative for this problem ))

Similar Threads

  1. Replies: 9
    Last Post: 26th May 2010, 23:16
  2. QFileDialog Filter Selector
    By SixDegrees in forum Qt Programming
    Replies: 0
    Last Post: 7th May 2010, 02:00
  3. QFileDialog and file extension
    By calhal in forum Qt Programming
    Replies: 3
    Last Post: 9th March 2010, 13:54
  4. QFileDialog filter
    By wirasto in forum Newbie
    Replies: 12
    Last Post: 20th January 2010, 13:40
  5. QFileDialog::getSaveFileName default extension
    By elcuco in forum Qt Programming
    Replies: 2
    Last Post: 10th August 2007, 21:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.