Hi.
The topic was discussed couple of time on this forum, but not in the way that satisfies me.
My tree looks like
name DESC
|-> ENTRY ID_100
|-> ENTRY ID_101
|-> ENTRY_2 ID_102
|-> ENTRY_2 ID_103
name DESC
|-> ENTRY ID_100
|-> ENTRY ID_101
|-> ENTRY_2 ID_102
|-> ENTRY_2 ID_103
To copy to clipboard, switch view to plain text mode
It has 2 columns, first with name and second with ID (unique) what I want to do is to find index of ENTRY, when having only ID, and I really don't know how to do that.
I'm now trying to use the match() function but with no success. When I look for text in first column everything works great.
Code
QModelIndexList Items = model->match(
model->index(0, 0),
Qt::DisplayRole,
-1,
Qt::MatchRecursive);
QModelIndexList Items = model->match(
model->index(0, 0),
Qt::DisplayRole,
QVariant::fromValue(QString("ENTRY_2")),
-1,
Qt::MatchRecursive);
To copy to clipboard, switch view to plain text mode
returns me indexes of all entries with same text, but changing code to
QModelIndexList Items = model->match(
model->index(0, 1),
Qt::DisplayRole,
-1,
Qt::MatchRecursive);
QModelIndexList Items = model->match(
model->index(0, 1),
Qt::DisplayRole,
QVariant::fromValue(102),
-1,
Qt::MatchRecursive);
To copy to clipboard, switch view to plain text mode
results in empty list of indexes.
Is there a simple way to find index of "ENTRY" by finding the ID?
Bookmarks