This article mainly summarizes the usage of the Qbytearray class, mainly summarizes how to assign a value of 16 to the Qbytearray object and display the hexadecimal number and hexadecimal number in the Qbytearray storage form, the specific example is as follows: (the hexadecimal number of characters: ' \ XFF ')
(QT Qbytearray Storage hexadecimal number is 0xFF, is actually stored in the ASCLL code, the storage form of ' \xff ', so if need to compare, need to use array.at (0) = = ' \xff ' expression, instead of array.at (0) = = 0xFF)
(to know whether the Qbytearray contains an int integer, or the character ' F ', if it is an int integer, it is judged by int or hex, and if the character ' F ' is the character ' F ', then it is judged by the characters:
For example, Qbytearray content is: FF, that is, qbytearray[0]=f,qbytearray[1]=f, then Qbytearray is stored two characters ' F ' instead of an integer 255.
For example Qbytearray content is: FF, that is, QBYTEARRAY[0]=FF, then Qbytearray is stored in an integer 255, instead of two characters ' FF '.
1.1 Create a new widget project, the base class is selected as Qwidget. Drag a pushbutton button into the UI interface.
1.2 Add the Slot function of the button and add the following code to the button slot function:
1.3 After the program is built, the results are as follows:
The above results indicate that the array array is 1 bytes long and can be assigned to the NO. 0 byte of array by hexadecimal number, i.e. code array[0] = 0xfE; When the hexadecimal number is assigned, the hexadecimal number takes up one byte of the array, and when you view the contents of the byte, you can use the function Tohex () to display the hexadecimal number (a byte of space). With the Qdebug class can be done, that is, Code Qdebug () <<array.tohex (); This functionality can be implemented. Of course, the assignment of 16 can also use characters to denote ' \x0fe ' = = 0xfE, that is, ' \x0fe ' is equivalent to 0xfE.
Reference content:
http://blog.csdn.net/u012627502/article/details/27060477 (explains how to modify the contents of an Qbytearray array, such as add, decrease, replace, middle Insert, start with n characters from the middle)