View Full Version : Problem with removeOne
zgulser
20th July 2012, 11:57
Hi,
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?
wysota
20th July 2012, 12:06
myList != _participantList ?
Also, what is "contact"? Does it have a comparison operator defined?
zgulser
20th July 2012, 12:23
Sorry for that,
Yes myList = _participantList.
No. I didn't define one but it derived from QObject.
wysota
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?
zgulser
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.
wysota
20th July 2012, 13:04
See what QList::contains() returns.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.