The method of obtaining the resolution of display by pyqt5

Time:2019-12-9

The code is as follows

import sys
			from PyQt5.QtWidgets import QApplication, QWidget
 
 
			class Example(QWidget):
 
			def __init__(self):
			super().__init__()
 
			self.initUI() 
			#Interface drawing to initui method
 
			def initUI(self):
 
			self.desktop = QApplication.desktop()
 
			#Get display resolution size
			self.screenRect = self.desktop.screenGeometry()
			self.height = self.screenRect.height()
			self.width = self.screenRect.width()
 
			print(self.height)
			print(self.width)
 
			#Show window
			self.show()
 
 
			if __name__ == '__main__':
			#Create applications and objects
			app = QApplication(sys.argv)
			ex = Example()
			sys.exit(app.exec_())

The above pyqt5 method to get the resolution of the display is all the content shared by the editor. I hope it can give you a reference, and I hope you can support developepaer more.