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

类型文档编制

qint8

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

qint16

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

qint32

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

qint64

typedef 对于 long long int 。 此类型保证在由 Qt 支持的所有平台都为 64 位。

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

qint64 value = Q_INT64_C(932838457459459);
					

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

[since 6.6] qint128

typedef 对于 __int128 在支持它的平台 (Qt 定义宏 QT_SUPPORTS_INT128 若是这种情况)。

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

该 typedef 在 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 对于无符号值。

为通过使用格式化输出设施打印这种类型的值,譬如 printf() , qDebug (), QString::asprintf () 等,可以使用 PRIdQINTPTR and PRIiQINTPTR 宏作为格式说明符。它们两者将打印以 10 为基数的值。

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 为无符号值。

为通过使用格式化输出设施打印这种类型的值,譬如 printf() , qDebug (), QString::asprintf () 等,可以使用 PRIdQPTRDIFF and PRIiQPTRDIFF 宏作为格式说明符。它们两者将打印以 10 为基数的值。

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 对于无符号值。

为通过使用格式化输出设施打印这种类型的值,譬如 printf() , qDebug (), QString::asprintf () 等,可以使用 PRIdQSIZETYPE and PRIiQSIZETYPE 宏作为格式说明符。它们两者将打印以 10 为基数的值。

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 对于 unsigned int 。此类型保证在 Qt 支持的所有平台为 32 位。

quint64

typedef 对于 unsigned long long int 。 此类型保证在由 Qt 支持的所有平台都为 64 位。

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

quint64 value = Q_UINT64_C(932838457459459);
					

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

[since 6.6] quint128

typedef 对于 unsigned __int128 在支持它的平台 (Qt 定义宏 QT_SUPPORTS_INT128 若是这种情况)。

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

该 typedef 在 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.

为通过使用格式化输出设施打印这种类型的值,譬如 printf() , qDebug (), QString::asprintf () and so on, you can use the following macros as format specifiers:

  • PRIuQUINTPTR :以 10 为基数打印值。
  • PRIoQUINTPTR :以 8 为基数打印值。
  • PRIxQUINTPTR :以 16 为基数打印值,使用小写 a-f 字母。
  • PRIXQUINTPTR :以 16 为基数打印值,使用大写 A-F 字母。
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 对于 unsigned 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

见 quintptr。

这些宏在 Qt 6.2 引入。

[since 6.2] PRIdQPTRDIFF

[since 6.2] PRIiQPTRDIFF

见 qptrdiff。

这些宏在 Qt 6.2 引入。

[since 6.2] PRIdQSIZETYPE

[since 6.2] PRIiQSIZETYPE

见 qsizetype。

这些宏在 Qt 6.2 引入。

[since 6.6] QT_SUPPORTS_INT128

Qt 定义此宏及 qint128 and quint128 类型若平台支持 128 位整数类型。

该宏在 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 )

包裹有符号 128 位整数 literal 以独立于平台的方式。

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

该宏在 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 .

此宏可用于 C++ 和 C 模式两者。

该宏在 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 .

此宏可用于 C++ 和 C 模式两者。

该宏在 Qt 6.6 引入。

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

qint64 Q_INT64_C ( literal )

包裹有符号 64 位整数 literal 以独立于平台的方式。

范例:

qint64 value = Q_INT64_C(932838457459459);
					

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

[since 6.6] quint128 Q_UINT128_C ( literal )

包裹无符号 128 位整数 literal 以独立于平台的方式。

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

该宏在 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 .

此宏可用于 C++ 和 C 模式两者。

最小化的 quint128 为 0 (零),因此 Q_UINT128_MIN 既不需要也不提供。

该宏在 Qt 6.6 引入。

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

quint64 Q_UINT64_C ( literal )

包裹无符号 64 位整数 literal 以独立于平台的方式。

范例:

quint64 value = Q_UINT64_C(932838457459459);
					

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