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中需要进行哪些更改才能进行编译。     

解决方法

根据Qt 4.6中的QString,只有一个候选者可以将指针作为参数。但是Qt 4.7中有两个QString构造函数可以将指针作为参数。我认为这引发了编译器错误。 您可以强制其行为类似于Qt 4.6,如下所示:
name((const char*) 0)
    ,无论您在创建带有int的QString的任何地方-您都需要告诉Qt int是什么意思 如果它是您要转换为字符串的实际文字数字,请使用QString(\“%u \”)。arg()函数