Removing items from a QList of pointers

只愿长相守 提交于 2019-12-12 04:55:35

问题


I have a QList of pointers to objects.

QList <MyObj*> mylist;

I add to the list as follows

mylist.append(new MyObj(1));
mylist.append(new MyObj(2));

So far so good.

So for exampple if I have a MyObj object and I want to search the list for a match how do I do it?

The indexOf memeber funcion requires that I have the comparison operator for MyObj, but MyObj does not have one.

So given a MyObj object, what is the best way to see if it is contained in the list?

Regards

来源:https://stackoverflow.com/questions/7539084/removing-items-from-a-qlist-of-pointers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!