Results 1 to 3 of 3

Thread: QRegExp on QSortFilterProxyModel

  1. #1
    Join Date
    May 2009
    Location
    Copenhagen
    Posts
    50
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default QRegExp on QSortFilterProxyModel

    I'm trying to filter out items from a soruce model (model) with the following values in the FilterKeyColumn;
    BALA,DRIF,120,5000

    I want to filter out the BALA row using QRegExp leaving the model with three items. I've tried using the following regular expression but it either retruns all four rows or no rows

    Qt Code:
    1. filterproxy->setSourceModel(model);
    2. filterproxy->setFilterKeyColumn(1);
    3. filterproxy->setFilterRegExp(QRegExp("(?!bala)",Qt::CaseInsensitive,QRegExp::FixedString) );
    4. tableview->setModel(proxymodel);
    To copy to clipboard, switch view to plain text mode 

    Basically what I want to do is to show all rows in the model except the row that has "bala" value in the FilterKeyColumn. The Qt Assistant is not really clear about negative expressions or how to apply a NOT validator.

    Can somebody help?

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

    Default Re: QRegExp on QSortFilterProxyModel

    I guess you don't want to use QRegExp::FixedString. Try QRegExp::RegExp or QRegExp::RegExp2.

  3. #3
    Join Date
    May 2009
    Location
    Copenhagen
    Posts
    50
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: QRegExp on QSortFilterProxyModel

    Hi Lykurg

    Thank you for replying.

    Changing the pattern syntax doesn't help. When using "bala" instead instead of "(?!bala)" only one row is accepted. This is exactly what I'm looking for - only opposite. Does RegExp contain a NOT keyword or symbol like !"bala"? It's not clear from the QSortFilterProxyModel class description nor the QRegExp description

Similar Threads

  1. QRegExp help
    By Lele in forum Qt Programming
    Replies: 2
    Last Post: 8th February 2008, 11:07
  2. QRegExp
    By szczav in forum Qt Programming
    Replies: 4
    Last Post: 19th June 2007, 21:07
  3. QRegExp?
    By Marco812 in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2006, 09:31
  4. need help for my QRegExp
    By patcito in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2006, 17:29
  5. QRegExp
    By evgenM in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2006, 15:22

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.