当前位置: 首页 > news >正文

美女网站源码张雷明任河南省委常委

美女网站源码,张雷明任河南省委常委,购买网络商城系统,莱阳做网站额,忘记了哪位哲人说过:“站在巨人的肩膀上,我们能看得更高!”嗯,大概就是这个意思了。这两天学习“一去二三里”大神博客里的Qt绘图事件,其中有一篇涉及到画圆盘,突然有想法,写个简易的抽奖小d…
  • 额,忘记了哪位哲人说过:“站在巨人的肩膀上,我们能看得更高!”嗯,大概就是这个意思了。这两天学习“一去二三里”大神博客里的Qt绘图事件,其中有一篇涉及到画圆盘,突然有想法,写个简易的抽奖小demo。了解了这种抽奖的原理和机制后,马丹,幸好没有买过各种彩票之类的,各种奖项的概率值分明是设置出来的嘛(我程序里是写死了)..好,先截个图:

choujaing

  • 简易能用。。哈哈
  • 头文件代码如下:
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QPainter>
#include <QRadialGradient>
#include <QPainterPath>
#include <QTimer>
#include <QDebug>
#include <QMouseEvent>
#include <QPushButton>
#include <QTime>
#include <QLabel>
#include <QLineEdit>
#include <QMap>
#include <QMapIterator>
#define MAX_CIRCLE  1800
namespace Ui {
class Widget;
}
class Widget : public QWidget
{Q_OBJECT
public:explicit Widget(QWidget *parent = 0);~Widget();void gradientArc(QPainter *painter,int radius,int startAngle,int angleLength,int arcHeight,QRgb color);
public slots:void updatePaint();void btnClicked();void reResult(int re);void stopRotate();
signals:void sigResult(int re);
private:Ui::Widget *ui;int m_nRotationAngle;int m_nRo;quint32 m_T;QString m_Re;QTimer *m_timer;QTimer *timer;int m_i;QPushButton *m_btn;bool isDefault;enum Awards{Spe = 3,First = 7,Second = 5,Third = 2,Luck_Fir = 6,Luck_Sec = 1,ThanK_Fir = 4,Thank_Sec = 0,};Awards m_award;QLabel *m_labTr;QLabel *m_labRe;QLineEdit *m_ldeRe;QMap<int,QString> m_map;QMap<int, QString> returnResult(int re);static QString showAwards(Awards award);void stopInit();int getRand();
protected:void paintEvent(QPaintEvent *);
};
#endif // WIDGET_H
  • 实现文件代码如下:
#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent) :QWidget(parent),ui(new Ui::Widget)
{ui->setupUi(this);resize(600,560);setMouseTracking(true);m_nRotationAngle = 0;m_i = 0;m_T = 0;isDefault = false;m_btn = new QPushButton(this);m_btn->move(273,450);m_labTr = new QLabel(tr("抽奖结果:"),this);m_labTr->move(223,105);m_ldeRe = new QLineEdit(tr("未开始抽奖"),this);m_ldeRe->move(293,103);m_ldeRe->setEnabled(false);m_ldeRe->setAlignment(Qt::AlignCenter);m_btn->setText(tr("启动"));m_timer = new QTimer(this);setStyleSheet("QLabel{""font-size:15px;""""}""QLineEdit{""color:white;""font-size:14px;""background-color:#f57ab8;""border:1px solid gray;""border-radius:5px;""}""QPushButton{""width:36px;""height:16px;""text-align:center;""background-color:#da0000;""color:white;""border:1px solid gray;""border-radius:3px;""}");connect(m_timer,SIGNAL(timeout()),this,SLOT(updatePaint()));connect(m_btn,SIGNAL(clicked(bool)),this,SLOT(btnClicked()));connect(this,SIGNAL(sigResult(int)),this,SLOT(reResult(int)));
}Widget::~Widget()
{delete ui;
}void Widget::gradientArc(QPainter *painter, int radius, int startAngle,int angleLength, int arcHeight, QRgb color)
{QRadialGradient gradient(0,0,radius);gradient.setColorAt(0,Qt::black);gradient.setColorAt(1.0,color);painter->setBrush(gradient);// << 1(左移1位)相当于radius*2 即:150*2=300//QRectF(-150, -150, 300, 300)QRectF rectf(-radius,-radius,radius << 1,radius << 1);QPainterPath path;path.arcTo(rectf,startAngle,angleLength);QPainterPath subPath;subPath.addEllipse(rectf.adjusted(arcHeight, arcHeight, -arcHeight, -arcHeight));//subPath.addEllipse(rect.adjusted(arcHeight,arcHeight,-arcHeight,-arcHeight));//path为扇形 subPath为椭圆path -= subPath;////        QFont font;//        font.setFamily("Microsoft YaHei");//        font.setPointSize(14);//        painter->setPen(Qt::NoPen);//        path.addText(path.pointAtPercent(0.5), font, QStringLiteral("一去丶二三里"));painter->setPen(Qt::NoPen);painter->drawPath(path);
}void Widget::updatePaint()
{if(!isDefault){m_nRotationAngle = m_nRotationAngle + 33;if(m_nRotationAngle >360){m_nRotationAngle = 0;m_T++;if(m_T == 3){m_nRotationAngle = m_nRotationAngle + 5;}else if(m_T == 5){stopInit();}}}else{m_nRotationAngle = m_nRotationAngle + 33;if(m_nRotationAngle >360){m_nRotationAngle = 0;m_T++;if(m_T == 3){m_nRotationAngle = m_nRotationAngle + 5;}else if(m_T == 5){stopInit();}}}update();
}void Widget::btnClicked()
{if(!m_timer->isActive()){m_timer->start(30);int iRangd = getRand();emit sigResult(iRangd);m_T = 0;m_ldeRe->setStyleSheet("color:white;");m_ldeRe->setText(tr("正在抽奖..."));}else{stopInit();}
}void Widget::reResult(int re)
{isDefault = true;m_map =  returnResult(re);QMapIterator<int,QString> ii(m_map);if(m_map.isEmpty())return;while(ii.hasNext()){ii.next();m_Re = ii.value();m_nRo = ii.key();}
}void Widget::stopRotate()
{m_timer->stop();
}QMap<int,QString> Widget::returnResult(int re)
{int ire = 0;QMap<int,QString> map;switch(re){case 0://(rand()%(b-a))+ a,-->[a,b)的随机数ire = (qrand() % (45 - 0) + 0);qDebug() << "二等奖";map.insert(ire,tr("二等奖"));break;case 1:qDebug() << "谢谢1";ire = (qrand() % (90 - 46) + 46);map.insert(ire,tr("谢谢参与"));break;case 2:qDebug() << "特等奖";ire = (qrand() % (135 - 90) + 90);map.insert(ire,tr("特等奖"));break;case 3:qDebug() << "三等奖";ire = (qrand() % (180 - 135) + 135);map.insert(ire,tr("三等奖"));break;case 4:qDebug() << "幸运2";ire = (qrand() % (225 - 180) + 180);map.insert(ire,tr("幸运奖"));break;case 5:qDebug() << "谢谢2";ire = (qrand() % (270 - 225) + 225);map.insert(ire,tr("谢谢参与"));break;case 6:qDebug() << "一等奖";ire = (qrand() % (315 - 270) + 270);map.insert(ire,tr("一等奖"));break;case 7:qDebug() << "幸运1";ire = (qrand() % (360 - 315) + 315);map.insert(ire,tr("幸运奖"));break;default:break;}return map;
}QString Widget::showAwards(Widget::Awards award)
{QString result = "";switch(award){case Spe:result = "特等奖";break;case First:result = "一等奖";break;case Second:result = "二等奖";break;case Third:result = "三等奖";break;case Luck_Fir:result = "幸运奖";break;case Luck_Sec:result = "幸运奖";break;case ThanK_Fir:result = "谢谢参与";break;case Thank_Sec:result = "谢谢参与";break;default:break;}return result;
}void Widget::stopInit()
{m_timer->stop();m_T = 0;isDefault = false;int ip =  m_nRo;int tp = m_nRotationAngle;if(ip > m_nRotationAngle){for (int i = tp; i <= ip; i++){m_nRotationAngle = i;}}m_nRotationAngle = m_nRo;m_ldeRe->setText(m_Re);update();
}//设置奖项概率
int Widget::getRand()
{int re = 10;QTime tim = QTime::currentTime();qsrand(tim.msec() + tim.second()*1000);int rand = ((qrand() % 100) + 1);qDebug() << "rand:" << rand;if(rand == 1){re = 2;}else if((rand <= 4) && (rand >= 2 )){re = 6;}else if((rand <= 9) && (rand >= 5 )){re = 0;}else if((rand <= 20) && (rand >= 10 )){re = 3;}else if((rand <= 35) && (rand >= 21 )){re = 4;}else if((rand <= 50) && (rand >= 36 )){re = 7;}else if((rand <= 75) && (rand >= 51 )){re = 1;}else if((rand <= 100) && (rand >= 76 )){re = 5;}return re;
}void Widget::paintEvent(QPaintEvent *)
{QPainter painter(this);painter.setRenderHint(QPainter::Antialiasing,true);int radius = 150;int arcHeight = 138;//>>1 右移一位,相当于width() / 2painter.translate(width() >> 1,height() >> 1);//    painter.rotate(m_nRotationAngle);/** 参数二:半径* 参数三:开始的角度* 参数四:指扫取的角度-顺时针(360度 / 8 = 45度)* 参数五:圆环的高度* 参数六:填充色**/gradientArc(&painter,radius,0,45,arcHeight,qRgb(200,200,0));gradientArc(&painter,radius,45,45,arcHeight,qRgb(200,0,200));gradientArc(&painter,radius,90,45,arcHeight,qRgb(0,200,200));gradientArc(&painter,radius,135,45,arcHeight,qRgb(200,0,0));gradientArc(&painter,radius,225,45,arcHeight,qRgb(0,200,0));gradientArc(&painter,radius,180,45,arcHeight,qRgb(0,0,200));gradientArc(&painter,radius,270,45,arcHeight,qRgb(0,0,0));gradientArc(&painter,radius,315,45,arcHeight,qRgb(150,150,150));painter.setPen(QPen(QColor(Qt::yellow),2));painter.rotate(-35);painter.drawText(60,30,tr("谢谢参与"));painter.rotate(40);painter.drawText(70,30,tr("一等奖"));painter.rotate(95);painter.drawText(70,30,tr("二等奖"));painter.rotate(135);painter.drawText(70,30,tr("三等奖"));painter.rotate(180);painter.drawText(70,30,tr("幸运奖"));painter.rotate(210);painter.drawText(70,30,tr("幸运奖"));painter.rotate(245);painter.drawText(70,30,tr("谢谢参与"));painter.rotate(40);painter.drawText(70,30,tr("特等奖"));QPainter painter2(this);painter2.setRenderHint(QPainter::Antialiasing,true);painter2.translate(width() >> 1,height() >> 1);painter2.rotate(m_nRotationAngle);static const QPoint poit[4] = {QPoint(0,-18),QPoint(10,0),QPoint(0,60),QPoint(-10,0)};painter2.setBrush(QColor(Qt::red));painter2.setPen(Qt::NoPen);painter2.drawPolygon(poit,4);painter2.setBrush(QColor(Qt::yellow));painter2.drawEllipse(-7,-7,14,14);
}
  • 我自己写的代码比较烂,各位看官嘴下留情…一直想实现的缓动效果,就是当针快要停下的时候缓慢的停下来。说是需要添加额外的库。水平有限,以后有机会再慢慢实现。

文章转载自:
http://yea.rwzc.cn
http://sibylic.rwzc.cn
http://alkyl.rwzc.cn
http://italianist.rwzc.cn
http://vitality.rwzc.cn
http://entomophagous.rwzc.cn
http://cabble.rwzc.cn
http://codicology.rwzc.cn
http://ashake.rwzc.cn
http://speculator.rwzc.cn
http://unmingled.rwzc.cn
http://subdue.rwzc.cn
http://aneurysmal.rwzc.cn
http://wired.rwzc.cn
http://catsuit.rwzc.cn
http://ungulate.rwzc.cn
http://scillonian.rwzc.cn
http://liar.rwzc.cn
http://tetrafluoride.rwzc.cn
http://plant.rwzc.cn
http://fanfaron.rwzc.cn
http://twosome.rwzc.cn
http://supersensitive.rwzc.cn
http://denominate.rwzc.cn
http://aforetime.rwzc.cn
http://teutonic.rwzc.cn
http://sora.rwzc.cn
http://nymphae.rwzc.cn
http://utp.rwzc.cn
http://thanky.rwzc.cn
http://matriculant.rwzc.cn
http://shellwork.rwzc.cn
http://caltrop.rwzc.cn
http://carom.rwzc.cn
http://bicyclist.rwzc.cn
http://pudsy.rwzc.cn
http://salvy.rwzc.cn
http://beibu.rwzc.cn
http://undecipherable.rwzc.cn
http://ciliary.rwzc.cn
http://doorframe.rwzc.cn
http://theatromania.rwzc.cn
http://macaw.rwzc.cn
http://hepatopexy.rwzc.cn
http://coalesce.rwzc.cn
http://methylate.rwzc.cn
http://kaiserism.rwzc.cn
http://gudgeon.rwzc.cn
http://widukind.rwzc.cn
http://blackmailer.rwzc.cn
http://sailboarding.rwzc.cn
http://dispassion.rwzc.cn
http://teletypewriter.rwzc.cn
http://rushed.rwzc.cn
http://oligodendroglia.rwzc.cn
http://cupriferous.rwzc.cn
http://otto.rwzc.cn
http://edgeless.rwzc.cn
http://pleiades.rwzc.cn
http://albumenize.rwzc.cn
http://phenomena.rwzc.cn
http://colorimeter.rwzc.cn
http://brickle.rwzc.cn
http://cutaway.rwzc.cn
http://lumpingly.rwzc.cn
http://commerciogenic.rwzc.cn
http://lyophiled.rwzc.cn
http://genitive.rwzc.cn
http://haberdashery.rwzc.cn
http://pinfeather.rwzc.cn
http://overprotect.rwzc.cn
http://invitation.rwzc.cn
http://chummy.rwzc.cn
http://jocularity.rwzc.cn
http://swanskin.rwzc.cn
http://barabbas.rwzc.cn
http://frightened.rwzc.cn
http://catatonic.rwzc.cn
http://pycnosis.rwzc.cn
http://diadochy.rwzc.cn
http://windsurf.rwzc.cn
http://haughtily.rwzc.cn
http://educationalist.rwzc.cn
http://shache.rwzc.cn
http://hasher.rwzc.cn
http://lloyd.rwzc.cn
http://muteness.rwzc.cn
http://bituminise.rwzc.cn
http://neuropterous.rwzc.cn
http://mixing.rwzc.cn
http://career.rwzc.cn
http://sacculated.rwzc.cn
http://distractive.rwzc.cn
http://cutaway.rwzc.cn
http://decauville.rwzc.cn
http://phencyclidine.rwzc.cn
http://erelong.rwzc.cn
http://fundamentalism.rwzc.cn
http://beneficially.rwzc.cn
http://incorporative.rwzc.cn
http://www.hrbkazy.com/news/74113.html

相关文章:

  • 成都哪里好玩一日游湛江百度seo公司
  • 中建装饰集团有限公司官网慧聪网seo页面优化
  • 企业网站托管哪家好天眼查询个人
  • 网页设计网站长沙win10优化
  • wordpress 密码忘记了杭州seo薪资水平
  • 做网站怎么带流量百度推广平台登陆
  • 设计师网站有哪些新手做网络销售难吗
  • 东莞网站设计多少钱seo和竞价排名的区别
  • 20m做网站如何自己开发一个网站
  • 安卓做视频网站好百度站长工具seo综合查询
  • 网站做更改后台怎么做百度收录官网
  • 设计软件有哪些手机版宁波营销型网站建设优化建站
  • 报名网站制作山东做网站公司
  • 网站开发的实例seo搜索引擎优化实训总结
  • 宜昌有做网站的公司吗交换友情链接的注意事项
  • 贵阳网站开发哪家好百度首页快速排名系统
  • 做传奇私服网站专业代写文案的公司
  • 现在什么传奇最火电脑版河南平价的seo整站优化定制
  • wordpress编辑器下载地址seopeix
  • 网站配置服务Wordpress网站建设方案及报价
  • 网站建设验收单媒体推广
  • 工信部网站域名查询ip域名查询网
  • 渝中网站建设网站友情链接购买
  • 广州建筑工程公司有哪些seo关键词排名软件
  • 茶社网站开发与设计的开题报告如何在百度上开店铺
  • 中华商标交易网官方网站杭州百度快照优化排名推广
  • 温州网站建设备案360关键词指数查询
  • web网站开发 框架seo实战培训教程
  • 内蒙古网站备案怎么做信息发布推广方法
  • 网站系统建设方案重庆seo技术教程