Results 1 to 4 of 4

Thread: QDirModel::setNameFilters(...) not working

  1. #1
    Join Date
    Dec 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QDirModel::setNameFilters(...) not working

    Hi,

    I want to create a QTreeView that only shows dirs and JPEG-files. When I pass end empty filter QStringList to the QDirModel constructor I can see all Dirs and Files, as expected. But when I try the same thing with a non-empty StringList I don't see anything.

    This snippet shows everything (since I create an empty StringList:
    Qt Code:
    1. filemodel = new QDirModel(QStringList(), \
    2. QDir::Files|QDir::Dirs|QDir::Readable|QDir::NoDotAndDotDot, \
    3. QDir::Name|QDir::DirsFirst, this);
    To copy to clipboard, switch view to plain text mode 

    This snippet doesn't show anything at all:
    Qt Code:
    1. QStringList ffilter;
    2. ffilter << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG";
    3. filemodel = new QDirModel(ffilter, \
    4. QDir::Files|QDir::Dirs|QDir::Readable|QDir::NoDotAndDotDot, \
    5. QDir::Name|QDir::DirsFirst, this);
    To copy to clipboard, switch view to plain text mode 

    Help appreciated, thx

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QDirModel::setNameFilters(...) not working

    Hi,

    is
    Qt Code:
    1. filemodel = new QDirModel(QStringList(), Dir::Files|QDir::Dirs|QDir::Readable|QDir::NoDotAndDotDot, QDir::Name|QDir::DirsFirst, this);
    2. QStringList ffilter;
    3. ffilter << "*.jpg" << "*.JPG" << "*.jpeg" << "*.JPEG";
    4. filemodel->setNameFilters(ffilter);
    To copy to clipboard, switch view to plain text mode 

    working?

    Lykurg

  3. #3
    Join Date
    Dec 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QDirModel::setNameFilters(...) not working

    no, assigning the filter after creating the DirModel doesn't work either. Same problem, the Treeview is empty.

  4. #4
    Join Date
    Oct 2008
    Location
    Taiwan
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDirModel::setNameFilters(...) not working

    Please add :

    filemodel ->setFilter( QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot );

    I tried and worked !

Similar Threads

  1. QResource Stopped Working
    By JPNaude in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 12:26
  2. QDevelop and CTags -> Not working
    By philwinder in forum Qt-based Software
    Replies: 13
    Last Post: 9th May 2008, 21:40
  3. Don't want QTextBrowser to look in working directory
    By magland in forum Qt Programming
    Replies: 1
    Last Post: 20th October 2007, 23:14
  4. setting working directory for current process
    By mule in forum Qt Programming
    Replies: 1
    Last Post: 8th October 2007, 13:54
  5. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31

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
  •  
Qt is a trademark of The Qt Company.