Details
-
Bug
-
Resolution: Done
-
P5: Not important
-
5.15.0
-
None
-
-
8455bfee76ed3f1bd3bba8bd3688a7afa94ae0bb (qt/qtbase/dev) 4796296ed6d7b05e2ba94e5a8a28c48350a3c492 (qt/qtbase/5.15)
Description
Attached is the test demo.untitled.zip
Before the proxy model calls the setsourcemodel, insert rows and columns for the source model, and then the proxy model cann't send the dataChanged signal.
The attachment codes are as follows:
#include <QCoreApplication> #include <QStandardItemModel> #include <QSortFilterProxyModel> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QStandardItemModel baseModel; QSortFilterProxyModel proxyModel; /************proxyModel can't emit datachanged*************************/ baseModel.insertRows(0, 1); baseModel.insertColumns(0, 1); /********************************************************************/ proxyModel.setSourceModel(&baseModel); /************proxyModel can emit datachanged*************************/ // baseModel.insertRows(0, 1); // baseModel.insertColumns(0, 1); /********************************************************************/ QObject::connect(&baseModel, &QStandardItemModel::dataChanged, []{ qDebug()<<"dataChanged emitted for the base model."; }); QObject::connect(&proxyModel, &QSortFilterProxyModel::dataChanged, []{ qDebug()<<"dataChanged emitted for the proxy model."; }); baseModel.setData(baseModel.index(0, 0), QStringLiteral("new data"), Qt::DisplayRole); return a.exec(); }