PyQt5 – Set fixed length for width/height of Status Bar

When window is resized status bar also get resized although we can set a fix size of status bar by using setFixedSize method with object of status bar. In this article we will see how we can only fix the length of either width or height i.e other side would be variable. In order to fix length of width we use setFixedWidth with object of status bar and to fix length of height we use setFixedHeight with object of status bar.
Syntax :
self.statusBar().setFixedHeight(height) self.statusBar().setFixedWidth(width)Argument : Both methods take integer as argument. Action performed : setFixedHeight fix the height of status bar. setFixedWidth fix the width of status bar.
Code :
Python3
| fromPyQt5.QtCore import*fromPyQt5.QtGui import*fromPyQt5.QtWidgets import*importsysclassWindow(QMainWindow):    def__init__(self):        super().__init__()        # set the title        self.setWindowTitle("Python")        # setting  the geometry of window        self.setGeometry(60, 60, 600, 400)        # setting status bar message        self.statusBar().showMessage("This isstatus bar")        # setting  border and padding with different sizes        self.statusBar().setStyleSheet("border :3pxsolid black;")        # setting fixed width        self.statusBar().setFixedHeight(100)        # creating a label widget        self.label_1 =QLabel("status bar", self)        # moving position        self.label_1.move(100, 100)        # setting up the border        self.label_1.setStyleSheet("border :1pxsolid blue;")        # resizing label        self.label_1.adjustSize()        # show all the widgets        self.show()# create pyqt5 appApp =QApplication(sys.argv)# create the instance of our Windowwindow =Window()# start the appsys.exit(App.exec()) | 
Output : 
 
				 
					



