1 Star 0 Fork 28

zhoujuan-ht17 / BPNNDemoQt

forked from Qt(开源集合) / BPNNDemoQt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
classifiertype.cpp 915 Bytes
一键复制 编辑 原始数据 按行查看 历史
ZzqiZQute 提交于 2018-11-20 17:43 . 201811201743
#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();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zhoujuan-ht17/BPNNDemoQt.git
git@gitee.com:zhoujuan-ht17/BPNNDemoQt.git
zhoujuan-ht17
BPNNDemoQt
BPNNDemoQt
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891