1 year ago
#104990
drn_svq
Remove and add widget from QStatusBar
I have an application with a status bar to which I would like to add/remove a permanent widget (because I need it on the right). My idea is simple: I have a QLabel widget initially hidden and it will be visible only when a user checks the checkbox.
The first time the users check the box, the widget is created perfectly, then hiding it back is as simple as QStatusBar::removeWidget(QWidget *widget)
, however, I am unable to add my widget back to my status bar since I have no clue how to implement the show() function. I read the documentation but is unclear to me:
void QStatusBar::removeWidget(QWidget *widget) Removes the specified widget from the status bar.
Note: This function does not delete the widget but hides it. To add the widget again, you must call both the addWidget() and show() functions.
Here is a small extract of my code:
def statusbarCheckbox(self, s):
if s.isChecked():
self.statusbar.addWidget(self.label_widget)
# what am I missing here?
# show() !?
else :
self.statusbar.removeWidget(self.label_widget)
I'm sure I'm missing some basic line on my if statement, which is when the widget should be shown again, but I am not sure what to add in there.
qt
pyqt
pyqt5
qstatusbar
0 Answers
Your Answer