9 Star 29 Fork 10

留天下 / 截屏软件

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
catchdialog.cpp 1.71 KB
一键复制 编辑 原始数据 按行查看 历史
#include "catchdialog.h"
#include "ui_catchdialog.h"
CatchDIalog::CatchDIalog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CatchDIalog)
{
ui->setupUi(this);
setWindowOpacity(0.5);
isMousePress=false;
this->setMaximumSize(QApplication::desktop()->width(),QApplication::desktop()->height());
this->setMinimumSize(QApplication::desktop()->width(),QApplication::desktop()->height());
}
CatchDIalog::~CatchDIalog()
{
delete ui;
}
void CatchDIalog::moveEvent(QMoveEvent *)
{
this->move(0,0);
}
QPixmap CatchDIalog::getPixmap()
{
return pixmap;
}
void CatchDIalog::mousePressEvent(QMouseEvent * event)
{
isMousePress=true;
this->thisFirst.setX(event->x());
this->thisFirst.setY(event->y());
this->globalFirst.setX(event->globalX());
this->globalFirst.setY(event->globalY());
}
void CatchDIalog::mouseReleaseEvent(QMouseEvent *event)
{
isMousePress=false;
this->thisSecond.setX(event->x());
this->thisSecond.setY(event->y());
this->globalSecond.setX(event->globalX());
this->globalSecond.setY(event->globalY());
pixmap=QPixmap::grabWindow(QApplication::desktop()->winId(),globalFirst.x(),globalFirst.y(),globalSecond.x()-globalFirst.x(),globalSecond.y()-globalFirst.y());
this->close();
}
void CatchDIalog::mouseMoveEvent(QMouseEvent * event)
{
if(isMousePress)
{
rect.setRect(thisFirst.x(),thisFirst.y(),event->x()-thisFirst.x(),event->y()-thisFirst.y());
this->update();
}
}
void CatchDIalog::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(Qt::red);
painter.setBrush(Qt::SolidPattern);
painter.drawRect(rect);
}
C++
1
https://gitee.com/lsylovews/jiepingruanjian.git
git@gitee.com:lsylovews/jiepingruanjian.git
lsylovews
jiepingruanjian
截屏软件
master

搜索帮助