1 Star 0 Fork 82

kuaileapp / Landlords

forked from ibc-dabing / Landlords 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mybutton.cpp 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
kevin 提交于 2021-12-07 23:24 . add file
#include "mybutton.h"
#include <QMouseEvent>
#include <QPainter>
MyButton::MyButton(QWidget *parent) : QPushButton(parent)
{
}
void MyButton::setImage(QString normal, QString hover, QString pressed)
{
m_normal = normal;
m_hover = hover;
m_pressed = pressed;
m_pixmap.load(m_normal);
update();
}
void MyButton::mousePressEvent(QMouseEvent *ev)
{
if(ev->button() == Qt::LeftButton)
{
m_pixmap.load(m_pressed);
update();
}
QPushButton::mousePressEvent(ev);
}
void MyButton::mouseReleaseEvent(QMouseEvent *ev)
{
if(ev->button() == Qt::LeftButton)
{
m_pixmap.load(m_normal);
update();
}
QPushButton::mouseReleaseEvent(ev);
}
void MyButton::enterEvent(QEvent *ev)
{
Q_UNUSED(ev)
m_pixmap.load(m_hover);
update();
}
void MyButton::leaveEvent(QEvent *ev)
{
Q_UNUSED(ev)
m_pixmap.load(m_normal);
update();
}
void MyButton::paintEvent(QPaintEvent *ev)
{
Q_UNUSED(ev)
QPainter p(this);
p.drawPixmap(rect(), m_pixmap);
}
1
https://gitee.com/kuaileapp/landlords.git
git@gitee.com:kuaileapp/landlords.git
kuaileapp
landlords
Landlords
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891