0

How can I hide / exclude entire rows from a QStandardItemModel without removing them physically from the model?

Rational: I want to not display entities which are shown in another view. I already have a working highlight logic for that in the data function. Could I turn it(easily) in a "not display logic", so such rows are skipped?

    QVariant CMyModel::data(const QModelIndex &index, int role) const
    {
        if (role != Qt::BackgroundRole) { return CModelBase::data(index, role); }
        .......

        if (model.hasSomeCondition())
        {
           static const QBrush b(Qt::green);
           return b;
        }
        return QVariant();
    }
Horst Walter
  • 13,663
  • 32
  • 126
  • 228

0 Answers0