0

I've created a SortFilterProxyModel together with a QStandardItemModel and a QTreeView. I need to only show rows, where the second column is equal to one of the values in my QStringList. Can anyone tell me how to do this? I thought of setFilterFixedString, but this only works for a single QString, not for a List...

My Code:

#include "dicomtagsproxymodel.h"


DicomTagsProxyModel::DicomTagsProxyModel(QObject *parent) : QSortFilterProxyModel(parent)
{
}

DicomTagsProxyModel::~DicomTagsProxyModel(void)
{
}

bool DicomTagsProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
    QModelIndex index1 = sourceModel()->index(sourceRow, 1, sourceParent);

    if (sourceModel()->data(index1).toString() == HOW TO GET THE VALUES OF MY STRINGLIST HERE?)
}
Engo
  • 899
  • 3
  • 19
  • 49

1 Answers1

1

You should subclass QSortFilterProxyModel then reimplement protected method virtual bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const. Inside reimplemented method you can check that value of index inside your QStringList.

Evgeny
  • 3,910
  • 2
  • 20
  • 37
  • I don't understand the last part: "Inside reimplemented method you can check that value of index inside your QStringList". How do I trigger this filtering, because the values in my stringlist change over time? – Engo Jan 20 '16 at 10:13
  • Then you should add to subclassed model some method for updating string list. – Evgeny Jan 20 '16 at 11:50