Answer the question
In order to leave comments, you need to log in
sound hover button. How to play a sound when hovering over a button?
I am making an application. I want to add a sound effect when hovering over a button.
Found a suitable inheritance code from the class. And it works well for me. How to add it to certain buttons?
pushButton_1
pushButton_3
pushButton_5
Form, Window = uic.loadUiType("HL_main.ui")
app = QApplication([])
window = Window()
form = Form()
form.setupUi(window)
window.setWindowFlags(QtCore.Qt.FramelessWindowHint)
class HoverButton(QPushButton):
def __init__(self, *args, **kwargs):
super(HoverButton, self).__init__(*args, **kwargs)
def enterEvent(self, e):
pygame.mixer.music.load('./res/musik/btn_hover.mp3')
pygame.mixer.music.play(0)
print("OK")
def leaveEvent(self, e):
pass
pushButton_12 = HoverButton(window)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question