首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QString类在Qt4.6和4.7之间的变化

QString类在Qt4.6和4.7之间的变化
EN

Stack Overflow用户
提问于 2011-04-13 21:38:19
回答 2查看 1.4K关注 0票数 1

我现在正在尝试用Qt4.7编译sqlitebrowser,在编译运行时我得到了他的错误:

代码语言:javascript
复制
g++ -c -pipe -O2 -Wall -W -DQT_NO_DEBUG -DQT_QT3SUPPORT_LIB -DQT3_SUPPORT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/share/qt4/mkspecs/freebsd-g++ -I. -I/usr/local/include/qt4/QtCore -I/usr/local/include/qt4/QtGui -I/usr/local/include/qt4/Qt3Support -I/usr/local/include/qt4 -Isqlite_source -I.moc -I/usr/local/include -o .obj/extendedmainform.o extendedmainform.cpp
In file included from findform.h:24,
                 from form1.h:31,
                 from extendedmainform.h:4,
                 from extendedmainform.cpp:1:
sqlitedb.h: In constructor 'DBBrowserField::DBBrowserField()':
sqlitedb.h:44: error: call of overloaded 'QString(int)' is ambiguous
/usr/local/include/qt4/QtCore/qstring.h:428: note: candidates are: QString::QString(const QByteArray&)
/usr/local/include/qt4/QtCore/qstring.h:426: note:                 QString::QString(const char*)
/usr/local/include/qt4/QtCore/qstring.h:728: note:                 QString::QString(const QString&)
/usr/local/include/qt4/QtCore/qstring.h:106: note:                 QString::QString(QChar)
/usr/local/include/qt4/QtCore/qstring.h:105: note:                 QString::QString(const QChar*)
sqlitedb.h: In constructor 'DBBrowserIndex::DBBrowserIndex()':
sqlitedb.h:58: error: call of overloaded 'QString(int)' is ambiguous
/usr/local/include/qt4/QtCore/qstring.h:428: note: candidates are: QString::QString(const QByteArray&)
/usr/local/include/qt4/QtCore/qstring.h:426: note:                 QString::QString(const char*)
/usr/local/include/qt4/QtCore/qstring.h:728: note:                 QString::QString(const QString&)
/usr/local/include/qt4/QtCore/qstring.h:106: note:                 QString::QString(QChar)
/usr/local/include/qt4/QtCore/qstring.h:105: note:                 QString::QString(const QChar*)
sqlitedb.h: In constructor 'DBBrowserTable::DBBrowserTable()':
sqlitedb.h:73: error: call of overloaded 'QString(int)' is ambiguous
/usr/local/include/qt4/QtCore/qstring.h:428: note: candidates are: QString::QString(const QByteArray&)
/usr/local/include/qt4/QtCore/qstring.h:426: note:                 QString::QString(const char*)
/usr/local/include/qt4/QtCore/qstring.h:728: note:                 QString::QString(const QString&)
/usr/local/include/qt4/QtCore/qstring.h:106: note:                 QString::QString(QChar)
/usr/local/include/qt4/QtCore/qstring.h:105: note:                 QString::QString(const QChar*)
*** Error code 1

我查看了Qt文档( 4.6和4.7)以查看Qstring构造函数中的任何更改,但我只看到一个新的one overload,所以我的问题是,为了编译它,我需要在sqlitebrowser中进行哪些更改。

EN

回答 2

Stack Overflow用户

发布于 2011-04-13 23:01:57

根据QString in Qt 4.6的说法,只有one candidate可以将指针作为参数。但是在Qt 4.7中有两个可以接受指针作为参数的QString构造函数。我认为这引发了编译器错误。

您可以强制它像Qt 4.6一样运行,如下所示:

代码语言:javascript
复制
name((const char*) 0)
票数 4
EN

Stack Overflow用户

发布于 2011-04-13 21:42:33

无论您在创建带有int的QString时,都需要告诉Qt您所说的int是什么意思

如果是要转换为字符串的实际文字数字,请使用QString("%u").arg()函数

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5650208

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档