I need to add a status bar beneath a table in a QVBoxLayout
. The problem is that I don't know why status bar is not shown. In the QBoxLayout
, I have added a tableView, under the table I need to have the status bar. Here is part of my code:
self.setGeometry(200,200,600,600)
if self._model.productName()!='':
self.setWindowTitle('TITLE')
QVBoxLayout(self).addWidget(self.tv)
# add staus bar
statusBar = QStatusBar()
statusLabel = QLabel("Here comes the status bar message!!")
statusBar.addWidget(statusLabel)
QVBoxLayout(self).addWidget(statusBar)
The ideal way to show a status bar would be to first inherit from the
QtGui.QMainWindow
class and then use thestatusBar
method to create the status bar.so inside your main class that creates the GUI, you can do this:
You can then show a message in the status bar in the following manner:
It is not required to use
QLabel
to show a status bar message.Alternatively, you can inherit from the
QtGui.QWidget
class and do this:Also, as one of the other answers points out, you are wrong with how the layout is created.
This should be the correct way to do it.