18

Regularly, I could reference limits.h to see what the max is for a certain type, like an int or long.

In Qt, there are types like qlonglong. Is there a header file and/or documentation that can be used in a similar way to manually or programmatically reference the limits of these types?

Cory Klein
  • 51,188
  • 43
  • 183
  • 243
  • 3
    There's a chance the Qt types distill down to one of the basic types- have you tried calling e.g., std::numeric_limits::max()? – fbrereto Jan 25 '11 at 00:14
  • @fbrereto: put that as an answer as this is very likely the case. – Tomek Jan 25 '11 at 07:44
  • 2
    Even when they're not typedefs for standard types, it's possible and indeed intended to specialize `std::numeric_limits` for numeric types. – MSalters Jan 25 '11 at 09:32

2 Answers2

17

There's a high likelihood the Qt types distill down to one of the basic types for which numeric_limits are defined. Have you tried calling e.g., std::numeric_limits<qlonglong>::max()?

As MSalters points out, too, if the types are not builtin numeric_limits can still be specialized for them. If that were the case one would hope Qt would include them.

fbrereto
  • 35,429
  • 19
  • 126
  • 178
3

Take a look at the QtGlobal documentation.

For some of the non-obvious ones:
qlonglong - 64-bit
qptrdiff - 32-bit or 64-bit depending on platform
qreal - double (float on ARM architectures)
quintptr - unsigned 32-bit or 64-bit depending on platform
qulonglong - unsigned 64-bit
uchar, uint, ulong, ushort - convenience shorthand for unsigned types

user2567875
  • 482
  • 4
  • 21
richardwb
  • 4,339
  • 33
  • 19
  • Are some of these deprecated since the header has become part of the standard ? Or if not deprecated, are they just specified as backward-compatible aliases ? The doc on the QtGlobal page seems very vague to me. – Johan Boulé Apr 20 '17 at 12:03