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

巩义网络建设网站wordpress官方主题

巩义网络建设网站,wordpress官方主题,龙海做网站费用,网络设计用什么软件1、概述 源码放在文章末尾 该项目实现了带动画效果的多选框#xff0c;鼠标放在上面或者选中都会呈现炫酷的动画效果#xff0c;demo演示如下#xff1a; 项目部分代码如下所示#xff1a; #ifndef LINEARCHECKBOX_H #define LINEARCHECKBOX_H#include QCheckBox …1、概述 源码放在文章末尾 该项目实现了带动画效果的多选框鼠标放在上面或者选中都会呈现炫酷的动画效果demo演示如下 项目部分代码如下所示 #ifndef LINEARCHECKBOX_H #define LINEARCHECKBOX_H#include QCheckBox #include QPropertyAnimation #include QPainter #include QPainterPath #include QDebugclass AniCheckBox : public QCheckBox {Q_OBJECTQ_PROPERTY(double hover_prog READ getHoverProg WRITE setHoverProg)Q_PROPERTY(double part_prog READ getPartProg WRITE setPartProg)Q_PROPERTY(double check_prog READ getCheckProg WRITE setCheckProg) public:AniCheckBox(QWidget* parent nullptr);void setForeColor(QColor c);protected:void paintEvent(QPaintEvent *) override;void enterEvent(QEvent *e) override;void leaveEvent(QEvent *e) override;bool hitButton(const QPoint ) const override;virtual void checkStateChanged(int state);virtual void drawBox(QPainter painter, QRectF rect);QPropertyAnimation* startAnimation(const QByteArray property, double begin, double end, int duration 500, QEasingCurve curve QEasingCurve::OutQuad);protected:double getHoverProg() const;void setHoverProg(double prog);double getPartProg() const;void setPartProg(double prog);double getCheckProg() const;void setCheckProg(double prog);protected:int boxSide 0; // 选择框边长0为自适应QColor foreColor QColor(#2753ff); // 前景颜色double hoverProg 0; // 鼠标移上去的进度double partyProg 0; // 部分选中的进度double checkProg 0; // 选中的进度 };#endif // LINEARCHECKBOX_H #include anicheckbox.hAniCheckBox::AniCheckBox(QWidget *parent) : QCheckBox(parent) {setCursor(Qt::PointingHandCursor);connect(this, QCheckBox::stateChanged, this, [](int state) {// qInfo() 状态变化 static_castQt::CheckState(state);checkStateChanged(state);}); }void AniCheckBox::setForeColor(QColor c) {this-foreColor c; }void AniCheckBox::paintEvent(QPaintEvent *) {// QCheckBox::paintEvent(e);QPainter painter(this);// painter.setRenderHint(QPainter::Antialiasing, true);QRectF rect;double textLeft;if (boxSide 0){// 自适应大小优先一行文字大小其次按比例const double fixedProp 0.8; // 默认比例QFontMetricsF fm(painter.font());double side fm.height(); // 一行文字的高度if (side this-height() * fixedProp)side this-height() * fixedProp;double margin side / 2;rect QRectF(margin, (height() - side) / 2, side, side);textLeft rect.right() margin;}else{// 固定大小double margin (this-height() - boxSide) / 2;rect QRectF(margin, margin, boxSide, boxSide);textLeft rect.right() margin;}// 绘制选择框painter.save();drawBox(painter, rect);painter.restore();// 绘制文字painter.save();painter.drawText(QRectF(textLeft, 0, this-width() - textLeft, this-height()), this-text(), Qt::AlignVCenter | Qt::AlignLeft);painter.restore(); }void AniCheckBox::enterEvent(QEvent *e) {QCheckBox::enterEvent(e);startAnimation(hover_prog, getHoverProg(), 1); }void AniCheckBox::leaveEvent(QEvent *e) {QCheckBox::leaveEvent(e);startAnimation(hover_prog, getHoverProg(), 0); }bool AniCheckBox::hitButton(const QPoint ) const {return true; }void AniCheckBox::checkStateChanged(int state) {if (state Qt::Unchecked){startAnimation(check_prog, getCheckProg(), 0, 800, QEasingCurve::OutBounce);}else if (state Qt::PartiallyChecked){}else if (state Qt::Checked){startAnimation(check_prog, getCheckProg(), 1, 500, QEasingCurve::OutBack);} }void AniCheckBox::drawBox(QPainter painter, QRectF rect) {painter.setPen(foreColor);painter.setRenderHint(QPainter::Antialiasing, true);// 绘制边缘方框和悬浮状态有关double radius 3;radius * (1 - hoverProg);painter.drawRoundedRect(rect, radius, radius);// 绘制选中状态int state this-checkState();double prop 0.6;prop * checkProg;rect QRectF(rect.left() rect.width() * (1 - prop) / 2,rect.top() rect.height() * (1 - prop) / 2,rect.width() * prop,rect.height() * prop);QPainterPath path;path.addRoundedRect(rect, radius, radius);painter.fillPath(path, foreColor);if (state Qt::Unchecked){}else if (state Qt::PartiallyChecked){}else if (state Qt::Checked){} }QPropertyAnimation *AniCheckBox::startAnimation(const QByteArray property, double begin, double end, int duration, QEasingCurve curve) {QPropertyAnimation* ani new QPropertyAnimation(this, property);ani-setStartValue(begin);ani-setEndValue(end);ani-setDuration(duration);ani-setEasingCurve(curve);connect(ani, SIGNAL(finished()), ani, SLOT(deleteLater()));connect(ani, SIGNAL(valueChanged(const QVariant)), this, SLOT(update()));ani-start();return ani; }double AniCheckBox::getHoverProg() const {return hoverProg; }void AniCheckBox::setHoverProg(double prog) {this-hoverProg prog; }double AniCheckBox::getPartProg() const {return partyProg; }void AniCheckBox::setPartProg(double prog) {this-partyProg prog; }double AniCheckBox::getCheckProg() const {return checkProg; }void AniCheckBox::setCheckProg(double prog) {this-checkProg prog; } 源码下载
http://www.w-s-a.com/news/325717/

相关文章:

  • 网站首页布局设计代码太仓网站开发建设服务
  • 学校网站建设与管理porto wordpress模板
  • 余姚做网站公司网站建设有哪些基本流程
  • 门户网站建设的报价百度医生在线问诊
  • 北京公司注册在哪个网站浏览器打开网址404
  • 廊坊做网站公司绣花图案设计网站
  • 网站空间租用哪个好购物网站建设模板图片
  • 建设银行包头分行网站泰安网签成交量最新
  • 手机微网站与微官网现在去成都需要隔离吗
  • 学校的二级网站怎么建设深圳企业网站制作设计
  • 自己做qq头像静态的网站网站建设是属于软件开发费吗
  • 举报网站建设做网站之前的工作
  • 用QQ群做网站排名个人网站制作协议
  • 做茶叶网站的素材天津网站营销
  • 网站设计建设流程图微信端的网站开发python
  • 湖州网站seo优化网站改域名备案
  • dedecms怎么制作网站合肥电商网站开发
  • 网站开发通用流程图做flash的网站
  • 营销型网站有哪些平台网站建设藤设计
  • 网站需求分析网站建设美食网站建设多少钱
  • 有专门做网站的吗建德网站
  • 做网站要买服务器吗单页设计思路
  • 一 电子商务网站建设规划网站开发前端框架和后端框架
  • 自助网站建设系统软件自己免费建设网站
  • 百度微建站access如何与网站连接数据库
  • ppt素材免费网站网站正能量晚上免费软件
  • 个人淘宝客网站如何备案搭建一个平台要多少钱
  • nginx 网站建设淘客网站怎么做首页
  • 网站制作的基本步骤是手机网站建设 新闻
  • 水墨 网站源码工装