Results 1 to 2 of 2

Thread: Qt5 use QSortFilterProxyModel slow in use setFilterFixedString()

  1. #1
    Join Date
    Jun 2024
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Question Qt5 use QSortFilterProxyModel slow in use setFilterFixedString()

    this is my first time use this blog,I am not good at English and I'm not familiar with the posting rules.
    I use Qt 5.15.3 centOs 7?use Qt Model view and QSortFilterProxModel filter data show?but use this is so slow.

    my test add source model item 100w,add changed all checkbox function and filter by name fucntion

    in my computer ,changed all checkbox use about 0.1s,filter name use about 12s.filter is so slow,i need this function better.

    this is like my code but not real use? please give me some advice.
    Qt Code:
    1. //init
    2. QListView* listView = new QListView(this);
    3. QSortFilterProxModel * filterModel = new QSortFilterProxModel (this);
    4.  
    5. int num = 1000000;
    6. for(int i =0; i< num;++i)
    7. {
    8. QstandardItem * item = new QStandardItem(QString("test%1).arg(i));
    9. item->setCheckable(true);
    10. item->setCheckState(Qt::Checked);
    11. model->appendRow(item);
    12. }
    13. filterModel->setSourceModel(model);
    14. filterModel->setDynamicSortFilter(false);
    15. listView->setModel(filterModel);
    16.  
    17. //function changed all checkbox?0.1s
    18. void changedCheckbox(bool isChecked)
    19. {
    20. this->beginResetModel();
    21. for(int i =0; i < rowCount();i++?
    22. {
    23. QStandardItem* item = model->item(i,0);
    24. item->setCheckState(isCheck ? Qt::checked : Qt::Unchecked);
    25. }
    26. this->endresetModel();
    27. }
    28. fucntion filter by name ?12s
    29. void changedFilter(QString name)
    30. {
    31. filterModel->setFilterFixedString(name);
    32. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 5th March 2025 at 13:17.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,366
    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: Qt5 use QSortFilterProxyModel slow in use setFilterFixedString()

    I would try without beginResetModel/endResetModel. Furthermore, QStandardItemModel will never be very performant.
    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. Replies: 1
    Last Post: 16th February 2022, 17:37
  2. (PyQt) QSortFilterProxyModel very slow when sorting
    By TheGrudge in forum Qt Programming
    Replies: 0
    Last Post: 17th January 2021, 13:44
  3. Replies: 10
    Last Post: 25th December 2014, 04:06
  4. Replies: 9
    Last Post: 11th April 2011, 11:05

Tags for this Thread

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.