QByteArray is ambiguous?
-
When I try to compile this code:
QByteArray data;
data.resize(m_socket->pendingDatagramSize());m_socket->readDatagram(data.data(), data.size(), &m_clientAddr, &m_clientPort); Log::write(QString("Data from socket: %1\n").arg(data));
I get the following error:
/home/johnmerlino/Programming/Gateway/gateway.cpp:396:58: error: call of overloaded ‘arg(QByteArray&)’ is ambiguous
/home/johnmerlino/Programming/Gateway/gateway.cpp:396:58: note: candidates are:
/usr/include/qt4/QtCore/qstring.h:132:13: note: QString QString::arg(qlonglong, int, int, const QChar&) const
/usr/include/qt4/QtCore/qstring.h:134:13: note: QString QString::arg(qulonglong, int, int, const QChar&) const
/usr/include/qt4/QtCore/qstring.h:747:16: note: QString QString::arg(long int, int, int, const QChar&) const
/usr/include/qt4/QtCore/qstring.h:749:16: note: QString QString::arg(ulong, int, int, const QChar&) const
/usr/include/qt4/QtCore/qstring.h:743:16: note: QString QString::arg(int, int, int, const QChar&) const
/usr/include/qt4/QtCore/qstring.h:745:16: note: QString QString::arg(uint, int, int, const QChar&) const
/usr/include/qt4/QtCore/qstring.h:751:16: note: QString QString::arg(short int, int, int, const QChar&) const
/usr/include/qt4/QtCore/qstring.h:753:16: note: QString QString::arg(ushort, int, int, const QChar&) const
/usr/include/qt4/QtCore/qstring.h:148:13: note: QString QString::arg(double, int, char, int, const QChar&) const
/usr/include/qt4/QtCore/qstring.h:150:13: note: QString QString::arg(char, int, const QChar&) const
/usr/include/qt4/QtCore/qstring.h:154:13: note: QString QString::arg(const QString&, int, const QChar&) constAny idea why this error occurs?
-
Either use another QString:
@
Log::write(QString(“Data from socket: %1\n”).arg(QString(data)));
@or simply use the string builder:
@
Log::write(QString(“Data from socket: " + data + "\n”));
@