使用QSet遇到的编译错误

本文介绍了在使用QSet时遇到的编译错误,由于QSet要求类型的`operator==()`和全局`qHash()`函数,而QPoint类型没有内置的qHash,故引发错误。通过为QPoint提供自定义的qHash函数,成功解决了编译问题。
摘要由CSDN通过智能技术生成

今天下午写了如下一段代码:

QSet pointSet;
pointSet.insert(QPoint());
编译后却得到一个编译错误:

error C2665: 'qHash' : none of the 16 overloads could convert all the argument types
1>        include/qtcore/../../src/corelib/tools/qhash.h(62): could be 'uint qHash(char)'
1>        include/qtcore/../../src/corelib/tools/qhash.h(63): or 'uint qHash(uchar)'
1>        include/qtcore/../../src/corelib/tools/qhash.h(64): or 'uint qHash(signed char)'
1>        include/qtcore/../../src/corelib/tools/qhash.h(65): or 'uint qHash(ushort)'
1>        include/qtcore/../../src/corelib/tools/qhash.h(66): or 'uint qHash(short)'
1>        include/qtcore/../../src/corelib/tools/qhash.h(67): or 'uint qHash(uint)'
1>        include/qtcore/../../src/corelib/tools/qhash.h(68): or 'uint

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值