Alquimista Alquimista - 7 months ago 144
Python Question

how code a Image button in PyQt?

Im trying to do simple audio player, but I want use a image(icon) as a pushbutton.

Answer

I've seen that a lot of people have this problem and decided to write a proper example on how to fix it. You can find it here: An example on how to make QLabel clickable The solution in my post solves the problem by extending QLabel so that it emits the clicked() signal. The extended QLabel looks something like this:

class ExtendedQLabel(QLabel):

    def __init__(self, parent):
        QLabel.__init__(self, parent)

    def mouseReleaseEvent(self, ev):
        self.emit(SIGNAL('clicked()'))

I hope this helps!