Fetch the repository succeeded.
#include "ClickPixLabel.h"
ClickPixLabel::ClickPixLabel(QWidget *parent):QLabel(parent)
{
}
void ClickPixLabel::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.save();
QPixmap pix(p);
QPixmap dst = pix.scaled(w*factor, h*factor,Qt::KeepAspectRatio,Qt::SmoothTransformation);
painter.drawPixmap(0*factor, 0*factor, dst);
QPen pen;
pen.setWidth(5*factor);
pen.setColor(Qt::blue);
if(!is_press)
painter.setPen(Qt::NoPen);
else
painter.setPen(pen);
painter.drawRect(0*factor, 0*factor, w*factor, h*factor);
painter.restore();
}
void ClickPixLabel::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton){
is_press = true;
emit pressed();
repaint();
}
QLabel::mousePressEvent(event);
}
void ClickPixLabel::mouseReleaseEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton){
is_press = false;
emit released();
repaint();
}
QLabel::mouseReleaseEvent(event);
}
void ClickPixLabel::setP(QString p){
this->p = p;
}
void ClickPixLabel::setX(float x){
this->x = x;
}
void ClickPixLabel::setY(float y){
this->y = y;
}
void ClickPixLabel::setW(float w){
this->w = w;
}
void ClickPixLabel::setH(float h){
this->h = h;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。