View Full Version : Problem with removeOne

20th July 2012, 11:57

I have such a list;

QList<QPointer<Contact>> myList;

I populated this list and it seems ok. But When I want to remove a contact like;

bool success = _participantList.removeOne(contact);

it doesn't remove it. And it's size remains the same.

Any ideas?

20th July 2012, 12:06
myList != _participantList ?

Also, what is "contact"? Does it have a comparison operator defined?

20th July 2012, 12:23
Sorry for that,

Yes myList = _participantList.

No. I didn't define one but it derived from QObject.

20th July 2012, 12:37
Yes myList = _participantList.

"=" or "=="? Is it the same list (meaning you used a wrong variable name) or is it a copy of the original list?

I didn't define one but it derived from QObject.

I just noticed we're talking about pointers. Are you passing the same pointer that is in the list or a different one that simply points to the same QObject?

20th July 2012, 12:52
No. There is no myList. I just wrote it to tell my problem. It should be;

QList<QPointer<Contact>> _participantList;

Your second claim is most probably the reason. I'm going to have a quick check now.

20th July 2012, 13:04
See what QList::contains() returns.