can not append 0x00 into a QByteArray
-
Hi,
I was just checking the functionality of my serial port and i wanted to try sending a 0x00 , but this is what i get -error: call of overloaded ‘append(int)’ is ambiguous
153 | message.append(0x00) ;
| ~~~~~~~~~~~^
but there is no problem using any other value, am i missing something again?
and yes, i did read the documentation , i know it says that " if count is negative or zero nothing is appended" but this is something that i need to send...
-
Hi,
I was just checking the functionality of my serial port and i wanted to try sending a 0x00 , but this is what i get -error: call of overloaded ‘append(int)’ is ambiguous
153 | message.append(0x00) ;
| ~~~~~~~~~~~^
but there is no problem using any other value, am i missing something again?
and yes, i did read the documentation , i know it says that " if count is negative or zero nothing is appended" but this is something that i need to send...
-
-
Hi,
I was just checking the functionality of my serial port and i wanted to try sending a 0x00 , but this is what i get -error: call of overloaded ‘append(int)’ is ambiguous
153 | message.append(0x00) ;
| ~~~~~~~~~~~^
but there is no problem using any other value, am i missing something again?
and yes, i did read the documentation , i know it says that " if count is negative or zero nothing is appended" but this is something that i need to send...
@agmar said in can not append 0x00 into a QByteArray:
but there is no problem using any other value, am i missing something again?
Your question des not state what type
message
is --- e.g.QByteArray
?QString
? --- so hard to answer for sure. For reference the issue is that C++ treats an integer value of0
specially, that matches any pointer type. So for exampleQByteArray::append()
has overloads which take achar ch
andconst char *str
. A value of0
would match the latter as well as the former (hence the ambiguity), but a value of1
is not "special" and would not match theconst char *str
pointer parameter. -
@agmar said in can not append 0x00 into a QByteArray:
but there is no problem using any other value, am i missing something again?
Your question des not state what type
message
is --- e.g.QByteArray
?QString
? --- so hard to answer for sure. For reference the issue is that C++ treats an integer value of0
specially, that matches any pointer type. So for exampleQByteArray::append()
has overloads which take achar ch
andconst char *str
. A value of0
would match the latter as well as the former (hence the ambiguity), but a value of1
is not "special" and would not match theconst char *str
pointer parameter.