如何在 PyQt 中编码图像按钮? [英] how code a Image button in PyQt?

查看:33
本文介绍了如何在 PyQt 中编码图像按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做简单的音频播放器,但我想使用图像(图标)作为按钮.

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

推荐答案

我看到很多人有这个问题,并决定写一个适当的例子来解决它.你可以在这里找到它:一个例子如何使 QLabel 可点击我帖子中的解决方案通过扩展 QLabel 使其发出 clicked() 信号来解决问题.扩展的 QLabel 看起来像这样:

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()'))

我希望这会有所帮助!

这篇关于如何在 PyQt 中编码图像按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆