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...
-
A agmar has marked this topic as solved on
-
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
messageis --- e.g.QByteArray?QString? --- so hard to answer for sure. For reference the issue is that C++ treats an integer value of0specially, that matches any pointer type. So for exampleQByteArray::append()has overloads which take achar chandconst char *str. A value of0would match the latter as well as the former (hence the ambiguity), but a value of1is not "special" and would not match theconst char *strpointer 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
messageis --- e.g.QByteArray?QString? --- so hard to answer for sure. For reference the issue is that C++ treats an integer value of0specially, that matches any pointer type. So for exampleQByteArray::append()has overloads which take achar chandconst char *str. A value of0would match the latter as well as the former (hence the ambiguity), but a value of1is not "special" and would not match theconst char *strpointer parameter.