<QtTypes> - Qt Type Declarations

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

头: #include <QtTypes>

类型

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

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

详细描述

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 无符号 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.

类型文档编制

qint8

typedef 对于 signed char 。此类型保证在 Qt 支持的所有平台为 8 位。

qint16

typedef 对于 signed short 。此类型保证在 Qt 支持的所有平台为 16 位。

qint32

typedef 对于 signed int 。此类型保证在 Qt 支持的所有平台为 32 位。

qint64

typedef 对于 long long int . This type is guaranteed to be 64-bit on all platforms supported by Qt.

可以创建此类型的文字使用 Q_INT64_C () 宏:

qint64 value = Q_INT64_C(932838457459459);
					

另请参阅 Q_INT64_C (), quint64 ,和 qlonglong .

[since 6.6] qint128

typedef 对于 __int128 on platforms that support it (Qt defines the macro QT_SUPPORTS_INT128 if this is the case).

可以创建此类型的文字使用 Q_INT128_C () 宏。

This typedef was introduced in Qt 6.6.

另请参阅 Q_INT128_C (), Q_INT128_MIN , Q_INT128_MAX , quint128 ,和 QT_SUPPORTS_INT128 .

qintptr

用于以有符号整数表示指针的整型 (对哈希等有用)。

typedef 为 qint32 或 qint64。此类型保证在 Qt 支持的所有平台,指针的大小相同。在采用 32 位指针的系统中,qintptr typedef 为 qint32;在采用 64 位指针的系统中,qintptr typedef 为 qint64。

注意,qintptr 有符号。使用 quintptr 对于无符号值。

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);
					

另请参阅 qptrdiff , qint32 ,和 qint64 .

qlonglong

typedef 对于 long long int ( __int64 在 Windows)。这如同 qint64 .

另请参阅 qulonglong and qint64 .

qptrdiff

用于表示指针差异的整型。

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.

注意:qptrdiff 是有符号的。使用 quintptr 为无符号值。

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);
					

另请参阅 quintptr , qint32 ,和 qint64 .

qreal

typedef 对于 double 除非配置 Qt 采用 -qreal float 选项。

[alias] qsizetype

整型类型提供 POSIX ssize_t 对于所有平台。

此类型保证相同大小如 size_t 在 Qt 支持的所有平台。

注意:qsizetype 无符号。使用 size_t 对于无符号值。

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);
					

另请参阅 qptrdiff .

quint8

typedef 对于 unsigned char 。此类型保证在 Qt 支持的所有平台为 8 位。

quint16

typedef 对于 unsigned short 。此类型保证在 Qt 支持的所有平台为 16 位。

quint32

typedef 对于 无符号 int 。此类型保证在 Qt 支持的所有平台为 32 位。

quint64

typedef 对于 unsigned long long int . This type is guaranteed to be 64-bit on all platforms supported by Qt.

可以创建此类型的文字使用 Q_UINT64_C () 宏:

quint64 value = Q_UINT64_C(932838457459459);
					

另请参阅 Q_UINT64_C (), qint64 ,和 qulonglong .

[since 6.6] quint128

typedef 对于 unsigned __int128 on platforms that support it (Qt defines the macro QT_SUPPORTS_INT128 if this is the case).

可以创建此类型的文字使用 Q_UINT128_C () 宏。

This typedef was introduced in Qt 6.6.

另请参阅 Q_UINT128_C (), Q_UINT128_MAX , qint128 ,和 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);
					

另请参阅 qptrdiff , quint32 ,和 quint64 .

qulonglong

typedef 对于 unsigned long long int ( unsigned __int64 在 Windows)。这如同 quint64 .

另请参阅 quint64 and qlonglong .

uchar

方便 typedef 对于 unsigned char .

uint

方便 typedef 对于 无符号 int .

ulong

方便 typedef 对于 unsigned long .

ushort

方便 typedef 对于 unsigned short .

宏文档编制

[since 6.2] PRIdQINTPTR

[since 6.2] PRIiQINTPTR

qintptr .

该函数在 Qt 6.2 引入。

[since 6.2] PRIXQUINTPTR

[since 6.2] PRIoQUINTPTR

[since 6.2] PRIuQUINTPTR

[since 6.2] PRIxQUINTPTR

See quintptr.

该函数在 Qt 6.2 引入。

[since 6.2] PRIdQPTRDIFF

[since 6.2] PRIiQPTRDIFF

See qptrdiff.

该函数在 Qt 6.2 引入。

[since 6.2] PRIdQSIZETYPE

[since 6.2] PRIiQSIZETYPE

See qsizetype.

该函数在 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.

[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.

另请参阅 qint128 , quint128 , Q_INT128_C (), Q_UINT128_C (), Q_INT128_MIN , Q_INT128_MAX ,和 Q_UINT128_MAX .

[since 6.6] qint128 Q_INT128_C ( literal )

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

注意: 不像 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.

另请参阅 qint128 , Q_UINT128_C (), Q_INT128_MIN , Q_INT128_MAX , Q_INT64_C (),和 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.

另请参阅 Q_INT128_MIN , Q_UINT128_MAX , qint128 , Q_INT128_C ,和 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.

另请参阅 Q_INT128_MAX , qint128 , Q_INT128_C ,和 QT_SUPPORTS_INT128 .

qint64 Q_INT64_C ( literal )

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

范例:

qint64 value = Q_INT64_C(932838457459459);
					

另请参阅 qint64 , Q_UINT64_C (),和 Q_INT128_C ().

[since 6.6] quint128 Q_UINT128_C ( literal )

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

注意: 不像 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.

另请参阅 quint128 , Q_INT128_C (), Q_UINT128_MAX , Q_UINT64_C (),和 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.

另请参阅 Q_INT128_MAX , quint128 , Q_UINT128_C ,和 QT_SUPPORTS_INT128 .

quint64 Q_UINT64_C ( literal )

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

范例:

quint64 value = Q_UINT64_C(932838457459459);
					

另请参阅 quint64 , Q_INT64_C (),和 Q_UINT128_C ().