Solved 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?
-
This post is deleted! -
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
int
can bind to multiple overloads ofQByteArray::push_back
you have to tell the compiler your byte constant is of typechar
and not the defaultint
:data.push_back(char(0x00));
ordata.push_back('\x00');
-
@aha_1980 That makes total sense. I did notice that when I cast 0x00 to char, it worked. I just didn't understand the reason. Thank you for the explanation!!!
-
@VRonin Thank you for the explanation!