📜  PyQt5 – 状态栏的 clearMessage()

📅  最后修改于: 2022-05-13 01:55:49.192000             🧑  作者: Mango

PyQt5 – 状态栏的 clearMessage()

PyQt5 支持窗口状态栏。这是有时会出现的窗口底部的一个小条,它可以包含文本消息。 clearMessage()方法用于清除由showMesaage()方法设置的状态栏上设置的消息。

代码 :

from PyQt5.QtCore import * 
from PyQt5.QtGui import * 
from PyQt5.QtWidgets import * 
import sys
  
  
class Window(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 is status bar")
  
        # clearing the status bar message
        self.statusBar().clearMessage()
  
        # creating a label widget
        self.label_1 = QLabel("No message in status bar", self)
  
        # moving position
        self.label_1.move(100, 100)
  
        # setting up the border
        self.label_1.setStyleSheet("border :1px solid blue;")
  
        # resizing label
        self.label_1.adjustSize()
  
        # show all the widgets
        self.show()
  
  
# create pyqt5 app
App = QApplication(sys.argv)
  
# create the instance of our Window
window = Window()
  
# start the app
sys.exit(App.exec())

输出 :