C++ Qt 类型的限制在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4788693/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where are the limits for Qt types?
提问by Cory Klein
Regularly, I could reference limits.h to see what the max is for a certain type, like an int or long.
通常,我可以参考limits.h 来查看某个类型的最大值是多少,例如int 或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?
在 Qt 中,有像 qlonglong 这样的类型。是否有头文件和/或文档可以以类似的方式用于手动或以编程方式引用这些类型的限制?
采纳答案by fbrereto
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()
?
Qt 类型极有可能被提炼为numeric_limits
定义的基本类型之一。你有没有试过打电话给例如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.
正如 MSalters 所指出的那样,如果类型不是内置的numeric_limits
,仍然可以为它们专门化。如果是这种情况,人们会希望 Qt 包含它们。
回答by richardwb
Take a look at the QtGlobaldocumentation.
查看QtGlobal文档。
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
对于一些不明显的:
qlonglong- 64 位
qptrdiff- 32 位或 64 位取决于平台
qreal- double(在 ARM 架构上浮动)
quintptr- 无符号 32 位或 64 位取决于平台
qulonglong-无符号 64 位
uchar、uint、ulong、ushort- 无符号类型的便捷简写