【问题标题】:Status bar not showing message状态栏不显示消息
【发布时间】:2014-07-11 17:19:30
【问题描述】:

看看下面的简单代码。我只是想在状态栏显示一条消息,但它没有显示。它没有返回错误...只是不显示消息。

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。

【问题讨论】:

    标签: python pyside statusbar


    【解决方案1】:

    如果您使用QVBoxLayout 而不是QHBoxLayout,则会显示该消息。 (但我不会说它看起来像一个合适的状态栏)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-18
      • 2019-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多