> > have you run  QAbstractItemModelTester
> > https://doc.qt.io/qt-6/qabstractitemmodeltester.html on the source
> > model and the proxy model?

Ok, I think I'm now using the tester, but I'm not sure I'm using it correctly. 
After I've populated my base model, assigned it as the source model to my 
proxy, and then connected the models up to their respective views I call:

    QAbstractItemModelTester* baseModelTester = new 
QAbstractItemModelTester(mBaseModel,
                                                                             
QAbstractItemModelTester::FailureReportingMode::Warning,
                                                                             
this);
    QAbstractItemModelTester* proxyModelTester = new 
QAbstractItemModelTester(mInvertRowsProxy,
                                                                              
QAbstractItemModelTester::FailureReportingMode::Warning,
                                                                              
this);

And then run the rest of my application normally. On first launch after adding 
those lines I saw the following statement twice in QtCreator's Application 
Output pane:

  qt.modeltest: FAIL! model->hasChildren(topIndex) () returned FALSE 
(qabstractitemmodeltester.cpp:366)

A quick google on that pointed to the fact that I was always returning my data 
size for rowCount() and 2 for columnCount() regardless of whether the parent 
index was valid or not. So adding:

if(parent.isValid())
    {
        return 0;
    }

to both rowCount() and columnCount() removed those errors and now my 
application runs silently.

Am I using the model index tester correctly?
Any other ideas on how to get this working?

Sean
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to