Qt 类型的限制在哪里?
通常,我可以参考 limit.h 来查看某种类型(例如 int 或 long)的最大值是多少。
在Qt中,有像qlonglong这样的类型。是否有头文件和/或文档可以以类似的方式使用来手动或以编程方式引用这些类型的限制?
Regularly, I could reference limits.h to see what the max is for a certain type, like an int or long.
In Qt, there are types like qlonglong. Is there a header file and/or documentation that can be used in a similar way to manually or programmatically reference the limits of these types?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Qt 类型很可能会分解为定义了
numeric_limits
的基本类型之一。您是否尝试过调用例如std::numeric_limits::max()
?正如 MSalters 也指出的那样,如果类型不是内置的,numeric_limits 仍然可以专门用于它们。如果是这样的话,人们会希望 Qt 能够包含它们。
There's a high likelihood the Qt types distill down to one of the basic types for which
numeric_limits
are defined. Have you tried calling e.g.,std::numeric_limits<qlonglong>::max()
?As MSalters points out, too, if the types are not builtin
numeric_limits
can still be specialized for them. If that were the case one would hope Qt would include them.查看 QtGlobal 文档。
对于一些不明显的:
qlonglong - 64 位
qptrdiff - 32 位或 64 位,具体取决于平台
qreal - 双精度(ARM 架构上的浮点数)
quintptr - 无符号 32 位或 64 位,具体取决于平台
qulonglong - 无符号 64 位
uchar、uint、ulong、ushort - 无符号类型的便捷简写
Take a look at the QtGlobal documentation.
For some of the non-obvious ones:
qlonglong - 64-bit
qptrdiff - 32-bit or 64-bit depending on platform
qreal - double (float on ARM architectures)
quintptr - unsigned 32-bit or 64-bit depending on platform
qulonglong - unsigned 64-bit
uchar, uint, ulong, ushort - convenience shorthand for unsigned types