Qt 4.6 和 4.7 之间 QString 类的变化
我现在尝试使用 Qt 4.7 编译 sqlitebrowser ,在编译运行时我收到错误:
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 构造函数中的任何更改,但我只看到一个新的 一个重载,所以我的问题是我需要在 sqlitebrowser 中更改什么为了编译它。
I am now trying to compile sqlitebrowser with Qt 4.7, during compilation run time I get his error:
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
I checked Qt documentation (both 4.6 and 4.7) to see any change in Qstring constructor, but I see only a new one overload, so my question what I need to change in sqlitebrowser in order to compile it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据Qt 4.6中的QString,只有一个候选者 可以将指针作为参数。但是 Qt 4.7 中有两个 QString 构造函数可以将指针作为参数。我认为这引发了编译器错误。
您可以强制它像 Qt 4.6 一样运行,如下所示:
According to QString in Qt 4.6, there is only one candidate that could take pointer as argument. But there are two QString constructors in Qt 4.7 that can take pointer as argument. I think this raised the compiler error.
You can force it to behave like Qt 4.6 as follows:
无论你在哪里创建一个带有 int 的 QString - 你需要告诉 Qt 你所说的 int 意味着什么
如果它是一个实际的文字数字,你要转换为字符串,请使用 QString("%u").arg() 函数
whereever you are creating a QString with an int - you need to tell Qt what you mean by an int
If it's an actual literal number you are converting to a string use the QString("%u").arg() function