Hi, this is my first time posting to this forum. I'm definitely a noob at both QT and c++, but with that said, I'm really liking both. Some of the details are killing me though. My problem is that I cannot delete an object from a QList Container. I can append just fine. Please see my code below.
---------------------------
class Contact{
public:
int category;
public:
//I don't know what this method is for
};
class ContactList{ //define class
public:
ContactList(); //constructor defined
QList<Contact> List; //this holds everything -- QList container class
void add(Contact c){
List.append(c); //this works just fine!
}
void remove(Contact c){
List.removeAll(c); //this does not work <-------------this is my problem line!
}
};
class Contact{
public:
Contact(int cat, QString fn, QString ln,
QString sa, QString zc, QString cityv,QString pn ); //Contact cstor
int category;
QString firstName;
QString lastName;
QString streetAddress;
QString zipCode;
QString city;
QString phoneNumber;
public:
QString toString(){}
//I don't know what this method is for
};
class ContactList{ //define class
public:
ContactList(); //constructor defined
QList<Contact> List; //this holds everything -- QList container class
void add(Contact c){
List.append(c); //this works just fine!
}
void remove(Contact c){
List.removeAll(c); //this does not work <-------------this is my problem line!
}
};
To copy to clipboard, switch view to plain text mode
---------------------
I've tried putting combinations of & and * on the parameters thinking maybe i need to use
a reference instead of actually passing an object, but nothing works. Thank you for any help
in this matter. I'm sure there is a very basic principle I'm missing, but as i said, I'm still learning.
oops, just noticed when i pasted text in here i have an extra "}" in there....that's just a typo and is not the cause of my problem. It definitely has to do with the fact that i'm trying to remove a class object from List
-Ryan
Bookmarks