admin管理员组

文章数量:1570220

原文

https://wwwblogs/syh6324/p/9502307.html

一、使用QDesktopWidget类实现

1.

QDesktopWidget的实例通过QApplication类的静态方法desktop()获取。

desktop =

QApplication.desktop()

2.

使用desktop的screenCount()方法获取显示器数量。

screen_count =

desktop.screenCount()

3.

使用desktop的screenGeometry()方法获取显示屏的几何位置和尺寸;使用desktop的availableGeometry()获取可用位置和尺寸(除去任务栏等)。

screen_rect =

desktop.screenGeometry(0)  #参数为显示屏索引,如果安装了两个显示屏,主显示屏索引为0,辅显示屏索引为1

available_rect

= desktop.availableGeometry(0)  #参数为显示屏索引,如果安装了两个显示屏,主显示屏索引为0,辅显示屏索引为1

4.

使用QWidget或QDialog类的setGeometry()方法就可以实现任一显示屏显示。

widget =

QWidget()

widget.setGeometry(desktop.screenGeometry(0)

#在主屏显示(全屏)。如果不打算全屏显示,只需将widget的geometry设置在desktop的geometry内就可以了。

dialog =

本文标签: 双屏信息显示屏屏幕Python