QSize 与使用 2 Int 有常量的比较
我正在做一个需要 2 个常量的项目:
Minimum Size of application (Width, Height)
Initial Size of application (Width, Height)
我想知道哪一个会消耗更少的内存:
1- 一个 QSize(该变量将包含初始宽度和 高度和该 QSize 的最小缩放比例)
2-4个整数(MinH、MinW、IniH、IniW)
感谢您的建议!
I'm doing a project needing 2 constants:
Minimum Size of application (Width, Height)
Initial Size of application (Width, Height)
I would like to know which would take less memory cossumption to do:
1- One QSize (which the variable would contain the initial width and
height and the minimum being scaled of this QSize)2- 4 ints (MinH, MinW, IniH, IniW)
Thanks for your suggestions !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
代码:
输出:
你计算一下。
Code:
Outputs:
you do the math.
不确定“此 QSize 的最小缩放比例”是什么意思。
QSize 本质上只是一个包装 2 个 int 的结构体,因此它使用与 2 个 int 相同的内存量。
我非常怀疑任何您需要担心 4 个整数的内存占用的平台的维度都会大于 64k,因此,如果内存确实是一个问题,您应该考虑使用 4 个无符号短整型而不是 4 个整数,这将使用一半的记忆。
Not sure what you mean by "the minimum being scaled of this QSize".
QSize is essentially just a struct wrapping 2 ints, so it uses the same amount of memory as 2 ints.
I doubt very much that any platform where you'd need to worry about the memory footprint of 4 integers would have dimensions greater than 64k, so if memory is really an issue you should consider using 4 unsigned shorts instead of 4 ints, which would use half the memory.