QByteArray - Ambiguous call to push_back???
-
Can anyone tell me why this line of code:
data.push_back(0x00);causes this error:
The call to member function 'push_back' is ambiguous?
Hi @ebonnett,
there are two overloads: http://doc.qt.io/qt-5/qbytearray.html#push_back-1 and http://doc.qt.io/qt-5/qbytearray.html#push_back-2
Your zero (0x00) can be converted to a char or a pointer, so the compiler don't know what to to.
If you want to append a char, use
data.push_back(char(0x00));Appending a nullpointer does not really makes sense, does it?!Regards
-
Hi @ebonnett,
there are two overloads: http://doc.qt.io/qt-5/qbytearray.html#push_back-1 and http://doc.qt.io/qt-5/qbytearray.html#push_back-2
Your zero (0x00) can be converted to a char or a pointer, so the compiler don't know what to to.
If you want to append a char, use
data.push_back(char(0x00));Appending a nullpointer does not really makes sense, does it?!Regards
-
Because
intcan bind to multiple overloads ofQByteArray::push_backyou have to tell the compiler your byte constant is of typecharand not the defaultint:data.push_back(char(0x00));ordata.push_back('\x00');