Results 1 to 3 of 3

Thread: QSqlTableModel :: setFilter() not working

  1. #1
    Join Date
    May 2016
    Posts
    10
    Thanks
    2
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Smile QSqlTableModel :: setFilter() not working

    model->setEditStrategy(QSqlTableModel::OnManualSubmit) ;
    model->setTable("people");
    model->setFilter("name = 'tinashe'");
    model->select();

    ui->tableView->setModel(model);


    I am trying to filter every name and only display " tinashe " I only get blank table view but when I substitute with
    model->setFilter("ID = 1 );
    IT WORKS WELL .

    please assist where am I wrong

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QSqlTableModel :: setFilter() not working

    Is there a "name" field in your table? And is the entry you are trying to filter actually "tinashe" (and not "Tinashe")?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    gotronics (13th August 2017)

  4. #3
    Join Date
    May 2016
    Posts
    10
    Thanks
    2
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: QSqlTableModel :: setFilter() not working

    thank you very much I solved the problem it was name did not match what was in database because when I edited before it using SQLITE database manager which did not submit the change into the database. so I deleted the table and created another one .

Similar Threads

  1. Using bindValue with QSqlTableModel.setFilter()
    By manuels in forum Qt Programming
    Replies: 0
    Last Post: 11th December 2010, 14:16
  2. qsqltablemodel "order by" clause in setfilter?
    By jtdavidson in forum Newbie
    Replies: 5
    Last Post: 10th August 2010, 02:58
  3. QSqlTablemodel->setFilter()
    By codeman in forum Qt Programming
    Replies: 4
    Last Post: 9th June 2009, 16:52
  4. QSqlTableModel setData not working?
    By jon-ecm in forum Qt Programming
    Replies: 10
    Last Post: 7th May 2009, 07:30
  5. QDataTable setFilter
    By cristiano in forum Qt Programming
    Replies: 10
    Last Post: 17th November 2006, 02:38

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.