Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QByteArray is ambiguous?
Qt 6.11 is out! See what's new in the release blog

QByteArray is ambiguous?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johnmerlino
    wrote on last edited by
    #1

    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&) const

    Any idea why this error occurs?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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”));
      @

      (Z(:^

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved