@RunThiner There's no need for such a loop. QSerialPort already provides an asynchronous API and if you really want to wait for data to be available, there's a blocking API for that as shown in the QSerialPort details.
@sdcr said:
(bites = sp->bytesAvailable())
Although it should return a reference to bites, it is not good coding practice imho.
http://en.cppreference.com/w/cpp/language/operator_assignment