6 Star 23 Fork 9

ZzqiZQute / ELMDemoQt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
classifiertype.cpp 915 Bytes
一键复制 编辑 原始数据 按行查看 历史
ZzqiZQute 提交于 2018-11-28 22:04 . first commit
#include "classifiertype.h"
#include <QPainter>
#include <algorithm>
#include <QPainterPath>
#include <QtMath>
using namespace std;
ClassifierType::ClassifierType(QWidget*)
{
}
int ClassifierType::type() const
{
return mType;
}
void ClassifierType::setType(int type)
{
mType = type;
}
void ClassifierType::paintEvent(QPaintEvent *)
{
QPainter painter;
painter.begin(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::black);
QPoint p(rect().width()/2,rect().height()/2);
int w=min(rect().width(),rect().height())*2/3;
QPainterPath path;
QPointF p2;
p2.rx()=p.x();
p2.ry()=p.y()-(w/2);
path.moveTo(p2);
for(int i=1;i<=mType+3;i++)
{
p2.rx()=p.x()+(w/2)*qFastSin(i*M_PI/(mType+3)*2);
p2.ry()=p.y()-(w/2)*qFastCos(i*M_PI/(mType+3)*2);
path.lineTo(p2);
}
painter.drawPath(path);
painter.end();
}
C++
1
https://gitee.com/ZzqiZQute/ELMDemoQt.git
git@gitee.com:ZzqiZQute/ELMDemoQt.git
ZzqiZQute
ELMDemoQt
ELMDemoQt
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891