Results 1 to 5 of 5

Thread: Filter in QTableView

  1. #1
    Join Date
    Mar 2016
    Posts
    10
    Qt products
    Qt5
    Platforms
    Windows

    Default Filter in QTableView

    My QTableView has this structure:
    Number, Month, Code.
    Numbers are in first column, months in second, codes in third.

    On example my tableview will looks so:
    200, 02, 23
    10, 02, 23
    30, 03, 24

    How can I do that function:
    if values in second and third column values are the same, then make one line(is it correct term?) with that values, and in the first column program must to show the sum of all values of first columns.

    So, the result must be:
    210, 02, 23
    30, 03, 24

    How to do that? I really need help.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Filter in QTableView

    One way is to create a proxy model that will aggregate the values. Another is to have a separate model that will keep the aggregated data and will recalculate itself when the base model changes.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Filter in QTableView

    What are you using as your model?

    Cheers,
    _

  4. #4
    Join Date
    Mar 2016
    Posts
    10
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Filter in QTableView

    I do that with my model
    Qt Code:
    1. QSqlQueryModel * model = new QSqlQueryModel(0);
    2. model->setQuery("select ......");
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Filter in QTableView

    Then why don't you aggregate the data using a "group by" clause in your query?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QwtPlot filter
    By simonb in forum Qwt
    Replies: 2
    Last Post: 10th July 2012, 16:15
  2. QFileDialog filter
    By wirasto in forum Newbie
    Replies: 12
    Last Post: 20th January 2010, 12:40
  3. Convolution filter
    By toutarrive in forum Qt Programming
    Replies: 5
    Last Post: 21st October 2009, 13:55
  4. regarding keyboard filter....
    By sar_van81 in forum Qt Programming
    Replies: 1
    Last Post: 2nd January 2007, 16:28
  5. filter processEvents
    By sreedhar in forum Qt Programming
    Replies: 1
    Last Post: 23rd March 2006, 11:16

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.