Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to mix QSortFilterProxyModel and QAbstractTableModel with fetch more function



  • Hi
    I'm using QTableView and a model inheriting QAbstractTableModel with fetch-more function like fetch more example.
    Now I want to add a filter. But I dont' know how to get the count of the data after filtering, to be used in fetch-more function. And how to update filtered data used in QAbstractTableModel::data()

    Regards
    Mihan



  • There is nothing special to do. fetchMore() notifies the proxy model of the new rows inserted via beginInsertRows/endInsertRows so there is nothing special to do. QSortfilterProxyModel will work automatically



  • @VRonin
    But I find that the list will not add new item but will update data if I just update the data vector and do not update the visible count.
    e.g.

    void updateData()
    {
        beginResetModel();
    
        GetDataVector(m_Vector);
    
        //without reset the visible count
        //m_VisibleCount = 0;
    
        endResetModel();
    }
    

    Also I find it will update well if I click the buttom item.

    how to improve it? Because I also want to real-time updata it.



  • @Mihan said in How to mix QSortFilterProxyModel and QAbstractTableModel with fetch more function:

    But I find that the list will not add new item but will update data if I just update the data vector and do not update the visible count.

    I'm sorry but I'm a bit slow. could you explain what you mean here?

    it will update well if I click the buttom item.

    what button item?


Log in to reply