• 7203阅读
  • 4回复

msvc版qt的问题 [复制链接]

上一主题 下一主题
离线sloadstar
 

只看楼主 倒序阅读 楼主  发表于: 2015-07-07
在windows下用qt,之前代码用mingw版本编译好好的,切到msvc版本就出来莫名其妙的问题,如下

C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore\qhash.h:102: error: C2665: “qHash”: 26 个重载中没有一个可以转换所有参数类型
c:\qt\qt5.4.2\5.4\msvc2013\include\qtcore\qdatetime.h(338): 可能是“uint qHash(const QTime &,uint) throw()”
c:\qt\qt5.4.2\5.4\msvc2013\include\qtcore\qdatetime.h(337): 或       “uint qHash(const QDate &,uint) throw()”
c:\qt\qt5.4.2\5.4\msvc2013\include\qtcore\qdatetime.h(336): 或       “uint qHash(const QDateTime &,uint)”
c:\qt\qt5.4.2\5.4\msvc2013\include\qtgui\qfont.h(313): 或       “uint qHash(const QFont &,uint) throw()”
e:\coding\qt\stockanalyzer_qt5\global\global_color.h(152): 或       “uint qHash(const CColorClass &)”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qurl.h(118): 或       “uint qHash(const QUrl &,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(92): 或       “uint qHash(QLatin1String,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(91): 或       “uint qHash(const QBitArray &,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(90): 或       “uint qHash(const QStringRef &,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(89): 或       “uint qHash(const QString &,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(88): 或       “uint qHash(const QByteArray &,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(87): 或       “uint qHash(const QChar,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(85): 或       “uint qHash(long double,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(83): 或       “uint qHash(double,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(82): 或       “uint qHash(float,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(81): 或       “uint qHash(qint64,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(77): 或       “uint qHash(quint64,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(76): 或       “uint qHash(long,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(70): 或       “uint qHash(ulong,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(69): 或       “uint qHash(int,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(68): 或       “uint qHash(uint,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(67): 或       “uint qHash(short,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(66): 或       “uint qHash(ushort,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(65): 或       “uint qHash(signed char,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(64): 或       “uint qHash(uchar,uint) throw()”
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(63): 或       “uint qHash(char,uint) throw()”
尝试匹配参数列表“(const CStockInfo)”时
C:\Qt\Qt5.4.2\5.4\msvc2013\include\QtCore/qhash.h(912): 参见对正在编译的函数 模板 实例化“uint qHash<Key>(const T &,uint)”的引用
with
[
    Key=CStockInfo



实在不知道怎么回事,为什么mingw之前就没有问题呢
离线stlcours

只看该作者 1楼 发表于: 2015-07-07
话先别说的太满。问一下,你的程序里有用到QHash类了吗?如果用了,那么<类型1,类型2>分别是什么,有没有为它重定义一个全局qHash函数?如果你可以信心满满的回答这三个问题,然后才可以怀疑有可能是QT的问题。
离线sloadstar

只看该作者 2楼 发表于: 2015-07-09
回 stlcours 的帖子
stlcours:话先别说的太满。问一下,你的程序里有用到QHash类了吗?如果用了,那么<类型1,类型2>分别是什么,有没有为它重定义一个全局qHash函数?如果你可以信心满满的回答这三个问题,然后才可以怀疑有可能是QT的问题。 (2015-07-07 19:44) 

用到了qlist,itme是我自定义的类,qlist在很多函数中都貌似会调用到qhash函数,原来mingw下,我是没有专门问自定义类提供这个函数的,没有出现这个问题,不明白为什么切到msvc以后就出现这种问题
离线彩阳

只看该作者 3楼 发表于: 2015-07-09
我看到了这一行:
e:\coding\qt\stockanalyzer_qt5\global\global_color.h(152): 或       “uint qHash(const CColorClass &)”
请检查一下这一行究竟发生了什么。
上海Qt开发联盟,热忱地欢迎你的加入!
离线stlcours

只看该作者 4楼 发表于: 2015-07-09
回 sloadstar 的帖子
sloadstar:用到了qlist,itme是我自定义的类,qlist在很多函数中都貌似会调用到qhash函数,原来mingw下,我是没有专门问自定义类提供这个函数的,没有出现这个问题,不明白为什么切到msvc以后就出现这种问题 (2015-07-09 15:35) 

我觉得是因为msvc类型匹配更严格?你之前没有自定义qHash却没有问题,我觉得只是一种巧合。
快速回复
限100 字节
 
上一个 下一个