<QtTypes> - Qt Type Declarations

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

头: #include <QtTypes>

类型

qint8
qint16
qint32
qint64
qintptr
qlonglong
qptrdiff
qreal
qsizetype
quint8
quint16
quint32
quint64
quintptr
qulonglong
uchar
uint
ulong
ushort

PRIXQUINTPTR
PRIdQINTPTR
PRIdQPTRDIFF
PRIdQSIZETYPE
PRIiQINTPTR
PRIiQPTRDIFF
PRIiQSIZETYPE
PRIoQUINTPTR
PRIuQUINTPTR
PRIxQUINTPTR
qint64 Q_INT64_C ( literal )
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 .

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 .

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.

qint64 Q_INT64_C ( literal )

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

范例:

qint64 value = Q_INT64_C(932838457459459);
					

另请参阅 qint64 and Q_UINT64_C ().

quint64 Q_UINT64_C ( literal )

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

范例:

quint64 value = Q_UINT64_C(932838457459459);
					

另请参阅 quint64 and Q_INT64_C ().