Results 1 to 2 of 2

Thread: How to filter QSqlRelationalTable?

  1. #1
    Join Date
    Mar 2007
    Posts
    2
    Qt products
    Qt4

    Default How to filter QSqlRelationalTable?

    When I do this :
    Qt Code:
    1. model->setTable("table");
    2. tableView->setModel(model);
    3. model->setFilter ("id = 660");
    To copy to clipboard, switch view to plain text mode 
    IT's Works!


    But when I do this :
    Qt Code:
    1. model->setTable("personne");
    2. model->setRelation(3, QSqlRelation("status", "id", "nom"));
    3. tableView->setItemDelegate(new QSqlRelationalDelegate(tableView));
    4. tableView->setModel(model);
    5. model->setFilter ("id = 660");
    To copy to clipboard, switch view to plain text mode 
    It's doesn't work !! Why ?

  2. #2
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to filter QSqlRelationalTable?

    Because you have to use the relationated filed name to filter...
    Qt Code:
    1. model->setTable("personne");
    2. model->setRelation(3, QSqlRelation("status", "id", "nom"));
    3. tableView->setItemDelegate(new QSqlRelationalDelegate(tableView));
    4. tableView->setModel(model);
    5. model->setFilter ("mon = *****");
    To copy to clipboard, switch view to plain text mode 
    Don`t now why, but seems to work that way...
    Last edited by tranfuga25s; 30th March 2007 at 17:38. Reason: reformatted to look better

Similar Threads

  1. Optimizing filterAcceptsRow() to filter a tree
    By vfernandez in forum Qt Programming
    Replies: 1
    Last Post: 4th January 2007, 12:50
  2. QSqlRelationalTable and filters
    By manucorrales in forum Qt Programming
    Replies: 1
    Last Post: 19th July 2006, 18:39
  3. Replies: 9
    Last Post: 31st March 2006, 13:07
  4. filter processEvents
    By sreedhar in forum Qt Programming
    Replies: 1
    Last Post: 23rd March 2006, 11:16
  5. Replies: 9
    Last Post: 5th March 2006, 03: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.