Results 1 to 6 of 6

Thread: Problem with removeOne

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Problem with removeOne

    Hi,

    I have such a list;

    Qt Code:
    1. QList<QPointer<Contact>> myList;
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. bool success = _participantList.removeOne(contact);
    To copy to clipboard, switch view to plain text mode 

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

    Any ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with removeOne

    myList != _participantList ?

    Also, what is "contact"? Does it have a comparison operator defined?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Problem with removeOne

    Sorry for that,

    Yes myList = _participantList.

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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with removeOne

    Quote Originally Posted by zgulser View Post
    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Problem with removeOne

    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Problem with removeOne

    See what QList::contains() returns.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.