C++ 为什么从QSortFilterProxyModel继承时不调用filterAcceptsRow?

C++ 为什么从QSortFilterProxyModel继承时不调用filterAcceptsRow?,c++,windows,qt,qsortfilterproxymodel,C++,Windows,Qt,Qsortfilterproxymodel,有一个名为customSortFilterProxyModel的类继承自QSortFilterProxyModel。一个受保护的功能过滤器AcceptsRow是override。 但是,根本不调用filterAcceptsRow。有什么问题? 谢谢 customSortFilterProxyModel.h class customSortFilterProxyModel: public QSortFilterProxyModel { Q_OBJECT

有一个名为customSortFilterProxyModel的类继承自QSortFilterProxyModel。一个受保护的功能过滤器AcceptsRow是override。 但是,根本不调用filterAcceptsRow。有什么问题? 谢谢 customSortFilterProxyModel.h

class customSortFilterProxyModel: public QSortFilterProxyModel
        {
           Q_OBJECT

        public:
            customSortFilterProxyModel(QObject *parent);
            ~customSortFilterProxyModel();

        protected:
           virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;   
        };

//customSortFilterProxyModel.cpp
customSortFilterProxyModel::customSortFilterProxyModel(QObject *parent)
: QSortFilterProxyModel(parent)
{
}
customSortFilterProxyModel::~customSortFilterProxyModel()
{

}
bool customSortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
   return true;
}
使用此代理模型测试代码

    QStringListModel *newModel = new QStringListModel;
    QStringList strList;
    strList << "1" << "2" << "3" << "4";
newModel->setStringList(strList);
    customSortFilterProxyModel   *m_customSortFilterProxyModel = new customSortFilterProxyModel(this);
       m_customSortFilterProxyModel->setSourceModel(newModel);
QStringListModel*newModel=新的QStringListModel;
QStringList strList;

strList为排序列调用此函数


m_CustomSortFilterProxy模型->排序(0)

我强制我的customSortFilterProxyModel通过 setSourceModel。它起作用了。但我不确定这是不是正确的解决方案