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.

Recommended Today

PDO data object in PHP

PDO: PHP data object: the data object of PHP.PDO is a database operation tool class!1. It can operate many kinds of databases, such as mysql, Oracle, Sybase….2. It has more functions to operate the database, such as transactions.3. It can operate all kinds of data, but it has the same syntax: that is to use […]