- Qt 6.8
- Qt Core
- <QtTypes> - Qt Type Declarations
- Qt 6.8.3 Reference Documentation

# <QtTypes> - Qt Type Declarations

The <QtTypes> header file includes Qt fundamental type declarations. More...

Header: | `#include <QtTypes>`

## Types

| qint8
| qint16
| qint32
| qint64
`(since 6.6)` | qint128
| qintptr
| qlonglong
| qptrdiff
| qreal
| qsizetype
| quint8
| quint16
| quint32
| quint64
`(since 6.6)` | quint128
| quintptr
| qulonglong
| uchar
| uint
| ulong
| ushort

## Macros

`(since 6.2)` |
`(since 6.2)` |
`(since 6.2)` |
`(since 6.2)` |
`(since 6.2)` | PRIXQUINTPTR
`(since 6.2)` | PRIdQINTPTR
`(since 6.2)` | PRIdQPTRDIFF
`(since 6.2)` | PRIdQSIZETYPE
`(since 6.2)` | PRIiQINTPTR
`(since 6.2)` | PRIiQPTRDIFF
`(since 6.2)` | PRIiQSIZETYPE
`(since 6.2)` | PRIoQUINTPTR
`(since 6.2)` | PRIuQUINTPTR
`(since 6.2)` | PRIxQUINTPTR
`(since 6.6)` | QT_SUPPORTS_INT128
`(since 6.6)` qint128 | Q_INT128_C(literal)
`(since 6.6)` | Q_INT128_MAX
`(since 6.6)` | Q_INT128_MIN
qint64 | Q_INT64_C(literal)
`(since 6.6)` quint128 | Q_UINT128_C(literal)
`(since 6.6)` | Q_UINT128_MAX
quint64 | Q_UINT64_C(literal)

## Detailed Description

The header file declares several type definitions that guarantee a specified bit-size on all platforms supported by Qt for various basic types, for example qint8 which is a signed char guaranteed to be 8-bit on all platforms supported by Qt. The header file also declares the qlonglong type definition for `long long int`.

Several convenience type definitions are declared: qreal for `double` or `float`, uchar for `unsigned char`, uint for `unsigned int`, ulong for `unsigned long` and ushort for `unsigned short`.

The header also provides series of macros that make it possible to print some Qt type aliases (qsizetype, qintptr, etc.) via a formatted output facility such as printf() or qDebug() without raising formatting warnings and without the need of a type cast.

## Type Documentation

### qint8

Typedef for `signed char`. This type is guaranteed to be 8-bit on all platforms supported by Qt.

### qint16

Typedef for `signed short`. This type is guaranteed to be 16-bit on all platforms supported by Qt.

### qint32

Typedef for `signed int`. This type is guaranteed to be 32-bit on all platforms supported by Qt.

### qint64

Typedef for `long long int`. This type is guaranteed to be 64-bit on all platforms supported by Qt.

Literals of this type can be created using the Q_INT64_C() macro:

     qint64 value = Q_INT64_C(932838457459459);

See also Q_INT64_C(), quint64, and qlonglong.

### `[since 6.6]` qint128

Typedef for `__int128` on platforms that support it (Qt defines the macro QT_SUPPORTS_INT128 if this is the case).

Literals of this type can be created using the Q_INT128_C() macro.

This typedef was introduced in Qt 6.6.

See also Q_INT128_C(), Q_INT128_MIN, Q_INT128_MAX, quint128, and QT_SUPPORTS_INT128.

### qintptr

Integral type for representing pointers in a signed integer (useful for hashing, etc.).

Typedef for either qint32 or qint64. This type is guaranteed to be the same size as a pointer on all platforms supported by Qt. On a system with 32-bit pointers, qintptr is a typedef for qint32; on a system with 64-bit pointers, qintptr is a typedef for qint64.

Note that qintptr is signed. Use quintptr for unsigned values.

In order to print values of this type by using formatted-output facilities such as `printf()`, qDebug(), QString::asprintf() and so on, you can use the `PRIdQINTPTR` and `PRIiQINTPTR` macros as format specifiers. They will both print the value as a base 10 number.

     qintptr p = 123;
     printf("The pointer is %" PRIdQINTPTR "\n", p);

See also qptrdiff, qint32, and qint64.

### qlonglong

Typedef for `long long int` (`__int64` on Windows). This is the same as qint64.

See also qulonglong and qint64.

### qptrdiff

Integral type for representing pointer differences.

Typedef for either qint32 or qint64. This type is guaranteed to be the same size as a pointer on all platforms supported by Qt. On a system with 32-bit pointers, quintptr is a typedef for quint32; on a system with 64-bit pointers, quintptr is a typedef for quint64.

Note that qptrdiff is signed. Use quintptr for unsigned values.

In order to print values of this type by using formatted-output facilities such as `printf()`, qDebug(), QString::asprintf() and so on, you can use the `PRIdQPTRDIFF` and `PRIiQPTRDIFF` macros as format specifiers. They will both print the value as a base 10 number.

     qptrdiff d = 123;
     printf("The difference is %" PRIdQPTRDIFF "\n", d);

See also quintptr, qint32, and qint64.

### qreal

Typedef for `double` unless Qt is configured with the `-qreal float` option.

### `[alias]` qsizetype

Integral type providing Posix' `ssize_t` for all platforms.

This type is guaranteed to be the same size as a `size_t` on all platforms supported by Qt.

Note that qsizetype is signed. Use `size_t` for unsigned values.

In order to print values of this type by using formatted-output facilities such as `printf()`, qDebug(), QString::asprintf() and so on, you can use the `PRIdQSIZETYPE` and `PRIiQSIZETYPE` macros as format specifiers. They will both print the value as a base 10 number.

     qsizetype s = 123;
     printf("The size is %" PRIdQSIZETYPE "\n", s);

See also qptrdiff.

### quint8

Typedef for `unsigned char`. This type is guaranteed to be 8-bit on all platforms supported by Qt.

### quint16

Typedef for `unsigned short`. This type is guaranteed to be 16-bit on all platforms supported by Qt.

### quint32

Typedef for `unsigned int`. This type is guaranteed to be 32-bit on all platforms supported by Qt.

### quint64

Typedef for `unsigned long long int`. This type is guaranteed to be 64-bit on all platforms supported by Qt.

Literals of this type can be created using the Q_UINT64_C() macro:

     quint64 value = Q_UINT64_C(932838457459459);

See also Q_UINT64_C(), qint64, and qulonglong.

### `[since 6.6]` quint128

Typedef for `unsigned __int128` on platforms that support it (Qt defines the macro QT_SUPPORTS_INT128 if this is the case).

Literals of this type can be created using the Q_UINT128_C() macro.

This typedef was introduced in Qt 6.6.

See also Q_UINT128_C(), Q_UINT128_MAX, qint128, and QT_SUPPORTS_INT128.

### quintptr

Integral type for representing pointers in an unsigned integer (useful for hashing, etc.).

Typedef for either quint32 or quint64. This type is guaranteed to be the same size as a pointer on all platforms supported by Qt. On a system with 32-bit pointers, quintptr is a typedef for quint32; on a system with 64-bit pointers, quintptr is a typedef for quint64.

Note that quintptr is unsigned. Use qptrdiff for signed values.

In order to print values of this type by using formatted-output facilities such as `printf()`, qDebug(), QString::asprintf() and so on, you can use the following macros as format specifiers:

- `PRIuQUINTPTR`: prints the value as a base 10 number.
- `PRIoQUINTPTR`: prints the value as a base 8 number.
- `PRIxQUINTPTR`: prints the value as a base 16 number, using lowercase `a-f` letters.
- `PRIXQUINTPTR`: prints the value as a base 16 number, using uppercase `A-F` letters.

     quintptr p = 123u;
     printf("The pointer value is 0x%" PRIXQUINTPTR "\n", p);

See also qptrdiff, quint32, and quint64.

### qulonglong

Typedef for `unsigned long long int` (`unsigned __int64` on Windows). This is the same as quint64.

See also quint64 and qlonglong.

### uchar

Convenience typedef for `unsigned char`.

### uint

Convenience typedef for `unsigned int`.

### ulong

Convenience typedef for `unsigned long`.

### ushort

Convenience typedef for `unsigned short`.

## Macro Documentation

### `[since 6.2]` PRIdQINTPTR

### `[since 6.2]` PRIiQINTPTR

See qintptr.

This function was introduced in Qt 6.2.

### `[since 6.2]` PRIXQUINTPTR

### `[since 6.2]` PRIoQUINTPTR

### `[since 6.2]` PRIuQUINTPTR

### `[since 6.2]` PRIxQUINTPTR

See quintptr.

This function was introduced in Qt 6.2.

### `[since 6.2]` PRIdQPTRDIFF

### `[since 6.2]` PRIiQPTRDIFF

See qptrdiff.

This function was introduced in Qt 6.2.

### `[since 6.2]` PRIdQSIZETYPE

### `[since 6.2]` PRIiQSIZETYPE

See qsizetype.

This function was introduced in Qt 6.2.

### `[since 6.6]` QT_SUPPORTS_INT128

Qt defines this macro as well as the qint128 and quint128 types if the platform has support for 128-bit integer types.

This macro was introduced in Qt 6.6.

See also qint128, quint128, Q_INT128_C(), Q_UINT128_C(), Q_INT128_MIN, Q_INT128_MAX, and Q_UINT128_MAX.

### `[since 6.6]` qint128 Q_INT128_C(literal)

Wraps the signed 128-bit integer literal in a platform-independent way.

Note: Unlike Q_INT64_C(), this macro is only available in C++, not in C. This is because compilers do not provide these literals as built-ins and C does not have support for user-defined literals.

This macro was introduced in Qt 6.6.

See also qint128, Q_UINT128_C(), Q_INT128_MIN, Q_INT128_MAX, Q_INT64_C(), and QT_SUPPORTS_INT128.

### `[since 6.6]` Q_INT128_MAX

This macro expands to a compile-time constant representing the maximum value representable in a qint128.

This macro is available in both C++ and C modes.

This macro was introduced in Qt 6.6.

See also Q_INT128_MIN, Q_UINT128_MAX, qint128, Q_INT128_C, and QT_SUPPORTS_INT128.

### `[since 6.6]` Q_INT128_MIN

This macro expands to a compile-time constant representing the minimum value representable in a qint128.

This macro is available in both C++ and C modes.

This macro was introduced in Qt 6.6.

See also Q_INT128_MAX, qint128, Q_INT128_C, and QT_SUPPORTS_INT128.

### qint64 Q_INT64_C(literal)

Wraps the signed 64-bit integer literal in a platform-independent way.

Example:

     qint64 value = Q_INT64_C(932838457459459);

See also qint64, Q_UINT64_C(), and Q_INT128_C().

### `[since 6.6]` quint128 Q_UINT128_C(literal)

Wraps the unsigned 128-bit integer literal in a platform-independent way.

Note: Unlike Q_UINT64_C(), this macro is only available in C++, not in C. This is because compilers do not provide these literals as built-ins and C does not have support for user-defined literals.

This macro was introduced in Qt 6.6.

See also quint128, Q_INT128_C(), Q_UINT128_MAX, Q_UINT64_C(), and QT_SUPPORTS_INT128.

### `[since 6.6]` Q_UINT128_MAX

This macro expands to a compile-time constant representing the maximum value representable in a quint128.

This macro is available in both C++ and C modes.

The minimum of quint128 is 0 (zero), so a `Q_UINT128_MIN` is neither needed nor provided.

This macro was introduced in Qt 6.6.

See also Q_INT128_MAX, quint128, Q_UINT128_C, and QT_SUPPORTS_INT128.

### quint64 Q_UINT64_C(literal)

Wraps the unsigned 64-bit integer literal in a platform-independent way.

Example:

     quint64 value = Q_UINT64_C(932838457459459);

See also quint64, Q_INT64_C(), and Q_UINT128_C().