我尝试使用以下代码:
QPoint pt;
QHash<QPoint, double> hexes;
hexes.contains(pt);
然后我得到了错误:
error: no matching function for call to ‘qHash(const QPoint&)’
但如果我将'QPoint‘替换为'int’,它就能正常编译。是否可以将QPoint用作QHash密钥类型?
发布于 2016-02-15 19:27:26
没有为QPoint
定义qHash
散列函数,但是可以使用QPair<int,int>
编写一个散列函数
inline uint qHash (const QPoint & key)
{
return qHash (QPair<int,int>(key.x(), key.y()) );
}
https://stackoverflow.com/questions/24498993
复制相似问题