Qt 4.6 和 4.7 之间 QString 类的变化

发布于 2024-11-01 05:00:45 字数 2779 浏览 3 评论 0原文

我现在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小矜持 2024-11-08 05:00:45

根据Qt 4.6中的QString,只有一个候选者 可以将指针作为参数。但是 Qt 4.7 中有两个 QString 构造函数可以将指针作为参数。我认为这引发了编译器错误。

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

name((const char*) 0)

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:

name((const char*) 0)
将军与妓 2024-11-08 05:00:45

无论你在哪里创建一个带有 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文