Results 1 to 1 of 1

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; 9th August 2024 at 09:05.

Similar Threads

  1. Replies: 1
    Last Post: 16th February 2022, 16:37
  2. (PyQt) QSortFilterProxyModel very slow when sorting
    By TheGrudge in forum Qt Programming
    Replies: 0
    Last Post: 17th January 2021, 12:44
  3. Replies: 10
    Last Post: 25th December 2014, 03:06
  4. Replies: 9
    Last Post: 11th April 2011, 10: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.