Results 1 to 2 of 2

Thread: Are "negative filters" possible??

  1. #1
    Join Date
    Nov 2007
    Posts
    47
    Thanks
    34
    Qt products
    Qt4
    Platforms
    Windows

    Default Are "negative filters" possible??

    This is how you can set filters on your QStringList (filenames).
    Qt Code:
    1. QStringList mylist;
    2. mylist << "*.jpg" << "*.bmp";
    3. dir.setNameFilters(mylist);
    To copy to clipboard, switch view to plain text mode 
    This is how you can set filters on your QString (filenames of a given folder).
    Qt Code:
    1. QString mystring = QFileDialog::getOpenFileName(this,
    2. tr("Open Image"), QDir::current().dirName(), tr("Image Files (*.jpg *.bmp)"));
    To copy to clipboard, switch view to plain text mode 

    I wonder if it is also possible to set negative filters? Instead of declaring what you want to see, I'd like to declare what I DON'T want to see? Does anyone know the syntax? For example: I don't want to see a file named "file.bmp", but "*.bmp" is allowed.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Are "negative filters" possible??

    Take a look at QStringList::filter().
    J-P Nurmi

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.