Screen information is available from the QApplication object as noted by ekhumoro. However, there should be only one global instance of QApplication. It is often set in the main script of a PyQt Gui application:
import sys
from PyQt5.QtWidgets import QApplication
def main():
...
app = QApplication(sys.argv)
window = MainWindow()
window.show
sys.exit(app.exec_())
That's probably not where you want to work with screen properties.
As pointed out by Omkar76, to access the global instance from elsewhere (e.g. in MainWindow()) use its instance() function. You can then use its primaryScreen property to get access to the many useful pieces of information available from the QScreen object:
from PyQt5.QtWidgets import QApplication, QMainWindow
class MainWindow(QMainWindow):
def __init__(self):
# Window dimensions
app = QApplication.instance()
screen = app.primaryScreen()
geometry = screen.availableGeometry()
self.setFixedSize(geometry.width() * 0.8, geometry.height() * 0.7)
QDesktopWidget is obsolete and so should be avoided.