Python 状态栏不显示消息
请看下面的简单代码。我只是想在状态栏上显示一条消息,但它没有显示。它不会返回错误。。。只是不要显示消息Python 状态栏不显示消息,python,pyside,statusbar,Python,Pyside,Statusbar,请看下面的简单代码。我只是想在状态栏上显示一条消息,但它没有显示。它不会返回错误。。。只是不要显示消息 class myForm(QtGui.QWidget): status_bar = None def __init__(self): super(myForm, self).__init__() self.InitializeComponent() def InitializeComponent(self): self.status_bar = QtG
class myForm(QtGui.QWidget):
status_bar = None
def __init__(self):
super(myForm, self).__init__()
self.InitializeComponent()
def InitializeComponent(self):
self.status_bar = QtGui.QStatusBar()
hbox_status_bar = QtGui.QHBoxLayout()
hbox_status_bar.addStretch(1)
hbox_status_bar.addWidget(self.status_bar)
self.setLayout(hbox_status_bar)
self.showMessage("Hello!")
self.show()
def showMessage(self, msg):
self.status_bar.showMessage(msg)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
ex = myForm()
sys.exit(app.exec_())
“我的表单”无法在QMainWindow中显示。如果使用
QVBoxLayout
而不是QHBoxLayout
,则会显示消息。(但我不会说它看起来像一个合适的状态栏)