QIODevice::bytesAvailable()是这么说的:Returns the number of bytes
that are available for reading. This function is commonly used with sequential
devices to determine the number of bytes to allocate in a buffer beforereading.
有一个Qt的例子是这样的:
{
uint time2u = 0;
QDataStream in(tcpSocket);
in.setVersion(QDataStream::Qt_4_3);
if(time2u==0)
{
if(tcpSocket->bytesAvailable()<(int)sizeof(uint)) return;
in>>time2u;
}
dateTimeEdit->setDateTime(QDateTime::fromTime_t(time2u));
getBtn->setEnabled(true);
}我想问的是上面代码里if(tcpSocket->bytesAvailable()<(int)sizeof(uint))是什么意思?
按理说tcpSocket->bytesAvailable()要比较应该是读到的字节数,怎么会是(int)sizeof(uint)呢?