Results 1 to 4 of 4

Thread: fast alternative for hiding of rows of QTableView

  1. #1
    Join Date
    Mar 2011
    Posts
    45
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default fast alternative for hiding of rows of QTableView

    hi folks,

    i am writing a software that displays logfile data within a QTableView.
    in some cases the displayed file content can be several 100 MB of size.

    I allready managed to put the whole content into the tableview by subclassing QAbstractTableModel in one go, so that works fine.

    but now the problem and would like to get some ideas in regard to this, hope u can help:

    there shall be filtering functionalities like: "find all rows that match a certain pattern"

    i thought maybe hiding the appropriate rows could be an option to display the result, but that turned out to be quite slow:

    Qt Code:
    1. QModelIndex start = tableModel->index(0, 0);
    2. QModelIndexList list = tableModel->match(start,
    3. Qt::DisplayRole,
    4. "*DEBUG*",
    5. -1,
    6. Qt::MatchWildcard);
    7.  
    8. ui->tableView->setUpdatesEnabled(false);
    9. for(ushort idx=0; idx<list.size();idx++)
    10. {
    11. int row = list[idx].row();
    12. ui->tableView->hideRow(row);
    13. }
    14. ui->tableView->setUpdatesEnabled(true);
    To copy to clipboard, switch view to plain text mode 

    i know that the parameters for tableModel::match(...) do certainly have an effect on speed, but i think its more the amount of rows within the table.

    so, any ideas how this kind of filtering could be implemented without having a bottle neck as this?
    hiding rows is not mandatory, so if u have other ideas how to display results i would appreciate.

    thnx alot.
    greets.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: fast alternative for hiding of rows of QTableView

    QSortFilterProxyModel is made for this sort of thing.

  3. #3
    Join Date
    Mar 2011
    Posts
    45
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: fast alternative for hiding of rows of QTableView

    ok, that looks good, but:

    within that qt-example u mention i changed the initial data to be 1000 times bigger (that is far less than i have) and what happens is,
    that the filtering functionality gets slow too: whenever one changes the filter it takes several seconds for the results view to be updated,
    so i am curious if this QSortFilterProxyModel is not just a kind of wrapper for the initial attempt of filtering (see my code above).

    the speed issue is still there i think.

  4. #4
    Join Date
    Mar 2011
    Posts
    45
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: fast alternative for hiding of rows of QTableView

    i would like to ask few question about filtering via QSortFilterProxyModel:

    in regard to the example from http://doc.qt.nokia.com/latest/itemv...ltermodel.html

    1. is it possible to be notified when the proxyfilter has finished filtering ? i would like the user to be informed that its working in the background and need to know when it has finished.

    2. after having finished i would like the user to be able to click on the view that contains the filter results and have the source-view containing the model-data to jump to the row the user has selected. how do i do that!?

    thnx alot.


    Added after 39 minutes:


    ok, i figured out how to do point 2:

    Qt Code:
    1. // //////////////////////////////////
    2. void MainWindow::on_tableView_2_pressed(QModelIndex index)
    3. // //////////////////////////////////
    4. {
    5. ui->tableView->setCurrentIndex( proxyModel->mapToSource(index) );
    6. }
    To copy to clipboard, switch view to plain text mode 

    but the currentIndex is not alway the topmost index within my source-view,
    means the relevant row within my source-view is not always the topmost row within the scroll-area.
    how do i achive that ??

    it would be nice if someone has an idea how to achive point 1


    Added after 8 minutes:


    ok, again for those interested:

    Qt Code:
    1. // //////////////////////////////////
    2. void MainWindow::on_tableView_2_pressed(QModelIndex index)
    3. // //////////////////////////////////
    4. {
    5. ui->tableView->setCurrentIndex( proxyModel->mapToSource(index) );
    6. ui->tableView->scrollTo(proxyModel->mapToSource(index), QAbstractItemView::PositionAtTop);
    7. }
    To copy to clipboard, switch view to plain text mode 
    does the magic.

    but still dont know how to achive point 1, help is appreciated.
    Last edited by kerim; 7th April 2011 at 15:11.

Similar Threads

  1. QTableView with icons in rows
    By kasper360 in forum Newbie
    Replies: 6
    Last Post: 5th April 2011, 06:24
  2. Disable row/rows in QTableView
    By scott_hollen in forum Qt Programming
    Replies: 6
    Last Post: 28th March 2011, 18:16
  3. QTableview Sorting and hiding
    By hmarani in forum Newbie
    Replies: 8
    Last Post: 28th February 2011, 15:05
  4. Replies: 3
    Last Post: 9th December 2010, 19:27
  5. QTableView 2 rows inside every row
    By skuda in forum Qt Programming
    Replies: 3
    Last Post: 22nd April 2009, 09:23

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.