<QtTypes> - Qt Type Declarations

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

Header: #include <QtTypes>

Types

Macros

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.

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.

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.2] PRIXQUINTPTR

This macro was introduced in Qt 6.2.

[since 6.2] PRIdQINTPTR

This macro was introduced in Qt 6.2.

[since 6.2] PRIdQPTRDIFF

This macro was introduced in Qt 6.2.

[since 6.2] PRIdQSIZETYPE

This macro was introduced in Qt 6.2.

[since 6.2] PRIiQINTPTR

This macro was introduced in Qt 6.2.

[since 6.2] PRIiQPTRDIFF

This macro was introduced in Qt 6.2.

[since 6.2] PRIiQSIZETYPE

This macro was introduced in Qt 6.2.

[since 6.2] PRIoQUINTPTR

This macro was introduced in Qt 6.2.

[since 6.2] PRIuQUINTPTR

This macro was introduced in Qt 6.2.

[since 6.2] PRIxQUINTPTR

This macro was introduced in Qt 6.2.

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 and Q_UINT64_C().

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 and Q_INT64_C().

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.