Python/PyQt4: How do you find the SIZE of a monito

2020-04-09 23:58发布

I'm trying to find the horizontal width of a monitor in inches or cm (not pixels!) to make a small "ruler" program. DPI would work too.

I'm using PyQt4.

1条回答
贼婆χ
2楼-- · 2020-04-10 00:45

try using the QDesktopWidget's width() and height() to get the width and height respectively. Class reference at QDesktopWidget Class Reference, this will give you the screens size in pixels and then use QX11Info.appDpiX, this will give you the DPI in pixels per inch. Use both the above info to calculate the screen size in inches.

PS: The width() returns the union width, so in case you have multiple screens, it will return union width of all the screens.

查看更多
登录 后发表回答