The row index changes few times in comparison to the number of times data
is called. Reduce the number of times your code instances a new object by
caching the object and creating a new one only when the row index changes.

Something like:

    QVariant data(const QModelIndex &index, int role) override
    {
        static int lastRow = -1;
        static QScopedPoint<MyDataClass> lastObj;
        if (lastObj.isNull() || index.row() != lastRow) {
            lastRow = index.row();
            lastObj.reset(createDataForRow(lastRow);
        }

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

Reply via email to