开发者

Why does Qt use qint64 for data lengths and offsets instead of quint64?

开发者 https://www.devze.com 2023-04-08 06:50 出处:网络
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 ty

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 and QIODevice::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.

0

精彩评论

暂无评论...
验证码 换一张
取 消