Use qstring toint () function with caution

Source: Internet
Author: User

Use the qstring toint () function with caution:

We are used to using the encapsulated functions provided by QT programming, but this requires extra attention. For the use of toint (A, 10) when a of the qstring type is converted to a decimal number, a can only contain 0-9 characters. If it contains other characters, the output is 0, leading to incorrect final result, it is also similar to 16 prohibitions. Then, if the data of the lower machine is received through the serial port, it will be troublesome to process the data types transmitted between the lower machine, for example, the data of the uchar type that may be transmitted by the lower computer may be ffffffffff22. In fact, it is only valid for 22. In this case, on the PC side, we need to perform the & 0xff operation on the received data that exceeds 0xff, or the lower computer will perform the & 0xff operation before transmission.

Use qstring toint () function with caution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.