It is necessary that when you hover the mouse over the elements of the toolbar, the value in the status bar does not change. I'm trying to intercept the mouse hover event, but the line change in the status bar still happens.

from PyQt5 import QtWidgets, QtCore import sys class _FilterConstructor(QtCore.QObject): def __init__(self, parent): super().__init__(parent) def eventFilter(self, obj, _event): if _event.type() == QtCore.QEvent.Enter: return True else: return QtCore.QObject.eventFilter(self, obj, _event) class MyWindow(QtWidgets.QMainWindow): def __init__(self): super().__init__() menu = self.menuBar() fileMenu = menu.addMenu('&File') evFilt = _FilterConstructor(fileMenu) fileMenu.installEventFilter(evFilt) self.statusBar().showMessage("line which doesn't want to disappear") if __name__ == '__main__': app = QtWidgets.QApplication(['']) root = MyWindow() root.show() sys.exit(app.exec_()) 

    2 answers 2

    For a QAction object, there is a special event that describes the action of updating the statusbar:

     QtCore.QEvent.StatusTip 

    Accordingly, the filter constructor code will look like this:

     class _FilterConstructor(QtCore.QObject): def __init__(self, parent): super().__init__(parent) def eventFilter(self, obj, _event): if _event.type() == QtCore.QEvent.StatusTip: return True else: return QtCore.QObject.eventFilter(self, obj, _event) 
       lb = QtWidgets.QLabel("protected text") self.statusBar().addPermanentWidget(lb) 

      for example, you can add a widget in statusBar and display the text there

      • Thanks, you can do this. But then the meaning is lost in the statusbar template. And I would like to understand how to do this through signals. - mkkik