Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 状态栏不显示消息_Python_Pyside_Statusbar - Fatal编程技术网

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
,则会显示消息。(但我不会说它看起来像一个合适的状态栏)