1 Star 0 Fork 3

OPMichael/QTLauncher

forked from murphy/QTLauncher 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
paintingwidget.cpp 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
murphy 提交于 2017-06-21 15:45 . add qt5 support & update README.md
#include "paintingwidget.h"
#include <QPen>
#include <QPainter>
#include <QPaintEvent>
#include <QPainterPath>
#include <QVBoxLayout>
#include <QtDebug>
namespace ui {
PaintingWidget::PaintingWidget(QWidget *parent)
:BaseWidget(parent)
{
centralLayout()->addStretch(1);
setWindowTitle("IRDA Test");
setFixedSize(QSize(800, 480));
}
PaintingWidget::~PaintingWidget()
{
}
void PaintingWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
QPen pen(Qt::black);
pen.setWidth(2);
painter.setPen(pen);
painter.drawPath(mPath);
}
void PaintingWidget::mousePressEvent(QMouseEvent *event)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
mPath.moveTo(event->posF());
mPrevPointF = event->posF();
#else
mPath.moveTo(event->localPos());
mPrevPointF = event->localPos();
#endif
update();
BaseWidget::mousePressEvent(event);
}
void PaintingWidget::mouseReleaseEvent(QMouseEvent *event)
{
update();
BaseWidget::mouseReleaseEvent(event);
}
void PaintingWidget::mouseMoveEvent(QMouseEvent *event)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
mPath.quadTo(mPrevPointF, event->posF());
mPrevPointF = event->posF();
#else
mPath.quadTo(mPrevPointF, event->localPos());
mPrevPointF = event->localPos();
#endif
update();
BaseWidget::mouseMoveEvent(event);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/michaelheaven/qtlauncher.git
git@gitee.com:michaelheaven/qtlauncher.git
michaelheaven
qtlauncher
QTLauncher
master

搜索帮助