作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图找到以英寸或厘米(不是像素!)为单位的显示器的水平宽度,以制作一个小的“标尺”程序。 DPI 也可以。
我正在使用 PyQt4。
最佳答案
尝试使用 QDesktopWidget 的 width() 和 height() 分别获取宽度和高度。类(class)引用 QDesktopWidget Class Reference , 这将为您提供以像素为单位的屏幕大小,然后使用 QX11Info.appDpiX ,这将为您提供以每英寸像素为单位的 DPI。使用以上信息计算屏幕尺寸(以英寸为单位)。
PS:width() 返回并集宽度,因此如果您有多个屏幕,它将返回所有屏幕的并集宽度。
关于 python /PyQt4 : How do you find the SIZE of a monitor (in inches)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19070370/
我是一名优秀的程序员,十分优秀!