How to build Side Bar Menu which shows on mouse hover on pyqt?
<p>I have been trying to build an app which has a dynamic side bar. I am using qtdesigner and pyqt5. I tryed in two ways:</p>

<p>1) Using stylesheet whith hover. But the sidebar (frame) has buttons on it. It happens that when I see the bar I just can see the button which has the mouse on.</p>

<p>stylesheetcode:</p>

<pre><code>QFrame {
                  background-color: rgba(255, 151, 231, 0); 
             }

QFrame:hover {
               background-color:rgba(255, 151, 231, 0.45)
            }

QPushButton {
                color: rgba(0, 0, 0, 0);
                background-color: rgba(255, 151, 231, 0);  
             }

QPushButton:hover {
               background-color:rgba(255, 151, 231, 0.45);
            }
</code></pre>

<p>output: (the mouse is over the button)</p>

<p><a href="https://i.stack.imgur.com/Kke2Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kke2Q.png" alt="enter image description here"></a></p>

<p>I know why it happens but I dont know how to solve it.</p>

<p>2) Using Events</p>

<p>Using events I can reach what I want, but I am not sure if I am doing the right thig.</p>

<pre><code>  class TelaPrincipal(QDialog, QMainWindow, Ui_Form):
    def __init__(self, parent=None):
        super(TelaPrincipal, self).__init__(parent)
        QDialog.__init__(self, parent)
        Ui_Form.__init__(self)
        self.setupUi(self)

        # -- Barra lateral esconde esconde --
        # instala esse EventFilter
        qApp.installEventFilter(self)
        QtCore.QTimer.singleShot(0, self.frame.hide)

    def eventFilter(self, source, event):
         # do not hide frame when frame shown
        if qApp.activePopupWidget() is None:
            if event.type() == QtCore.QEvent.MouseMove:
                if self.frame.isHidden():
                    self.frame.show()
                    rect = self.geometry()
                    # set mouse-sensitive zone
                    rect.setHeight(25)
                    if rect.contains(event.globalPos()):
                        self.frame.show()
                else:
                    rect = QtCore.QRect(
                        self.frame.mapToGlobal(QtCore.QPoint(0, 0)),
                        self.frame.size())
                    if not rect.contains(event.globalPos()):
                        self.frame.hide()
            elif event.type() == QtCore.QEvent.Leave and source is self:
                self.frame.hide()
        return QMainWindow.eventFilter(self, source, event)

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    main = TelaPrincipal()
    main.show()
    sys.exit(app.exec())
</code></pre>

<p>What do you suggest me ??</p>