Morteza.M
Morteza.M

Reputation: 177

qlist.count by a condition in qt

I have a Qlist of myStruct like QList<myStruct> list.

myStruct contains a bool parameter (active). i.e. I have list[i].active.

I want to count number of list elements that active parameter is equivalent to true.

I use qCount. But it needs a value to compare, not a condition.

what can I do? Thanks.

Upvotes: 0

Views: 596

Answers (1)

stanislav888
stanislav888

Reputation: 414

If you not want use simple loop as suggested before. You can support your own counter that will make appropriate increment\decrement when add\remove elements.

Upvotes: 1

Related Questions