QIODevice
and the related classes use qint64
for positions and sizes which is a signed datatype. Is there a need to exp开发者_Python百科ress negative values? Because otherwise the 8 bytes of such a type could be used to express greater sizes, couldn't they?
An error value of -1 is returned for several functions in QIODevice
. Qt often uses a C style of error handing using return values to avoid the need for a compiler or platform that supports the use of C++ exceptions. It is important to check for these error codes.
From the manual:
QIODevice::write
andQIODevice::writeData
Returns the number of bytes that were actually written, or -1 if an error occurred.
QIODevice::read(char*,qint64)
If an error occurs, ... this function returns -1.
QIODevice::readData(char*,qint64)
... and returns the number of bytes read or -1 if an error occurred.
QIODevice::peek(char*,qint64)
If an error occurs, ... this function returns -1.
精彩评论