How to resize the main window depending on the screen resolution using PyQt

I have a main window with three frames. The top frame consists of a header, and the bottom frame consists of a footer. I designed it with a constructor PyQt4. The window looks great when I run it on my laptop with a screen resolution 1920*1080. But when I check the same thing at different permissions, for example 1600*900, the footer is disabled. I wanted to know if there is a way to resize the window to fit the screen resolution at runtime so that all three frames are shown. I tried to check online if there are any solutions for this, but could not find. I tried using functions window.setGeometryand window.setFixedSize, but that did not work.

Code for the window:

import sys
import os
import threading
import smtplib

from PyQt4 import QtCore, QtGui, uic
import sched
import time

form_class = uic.loadUiType("FirstTest.ui")[0]                 # Load the UI
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    _fromUtf8 = lambda s: s

class MyWindowClass(QtGui.QMainWindow, form_class):
    def __init__(self, parent=None):
        QtGui.QMainWindow.__init__(self, parent)        
        self.setupUi(self)        

#has some code for the field values to be shown







app = QtGui.QApplication(sys.argv)
myWindow = MyWindowClass(None)
#myWindow.setFixedSize(500,500)
myWindow.showMaximized()
palette = QtGui.QPalette()
palette.setColor(QtGui.QPalette.Background,QtCore.Qt.white)
myWindow.setPalette(palette)
myWindow.show()
app.exec_()
+4
1
+4

All Articles