QSet如果元素是自定义结构,需要自定义qHash函数和operator()函数 自定义结构体
struct Box {
int mNum;
// other data member
};
自定义operator=函数
bool operator==(const Box& b1, const Box& b2)
{
return (b1.mNum == b2.mNum);
}
自定义qHash函数
int qHash(const Box& b)
{
return b.mNum;
}
定义
QSet<Box> sset;