ZIPQT实现弹跳按钮-自定义控件 26.91KB

u012959478

资源文件列表:

BounceButtonDemo.zip 大约有10个文件
  1. BounceButtonDemo/
  2. BounceButtonDemo/bouncebutton.cpp 1.92KB
  3. BounceButtonDemo/bouncebutton.h 366B
  4. BounceButtonDemo/BounceButtonDemo.pro 633B
  5. BounceButtonDemo/main.cpp 172B
  6. BounceButtonDemo/mainwindow.cpp 297B
  7. BounceButtonDemo/mainwindow.h 217B
  8. BounceButtonDemo/res/
  9. BounceButtonDemo/res/StartButton.png 36.79KB
  10. BounceButtonDemo/ui.qrc 98B

资源介绍:

Qt通过重新封装QPushButton类,实现自定义按钮,并且实现点击后的上下跳动特效。
#include "bouncebutton.h" #include <QPixmap> #include <QSize> #include <QPropertyAnimation> #include <QRect> #include <QEasingCurve> BounceButton::BounceButton(QString imgPath,QWidget *parent) : QPushButton(parent) { setImage(imgPath); connect(this,&BounceButton::clicked,[=](){this->zoom1();this->zoom2();}); } void BounceButton::zoom1(){ //创建动画对象 QPropertyAnimation *animation1 = new QPropertyAnimation(this,"geometry"); //设置时间间隔,单位毫秒 animation1->setDuration(200); //创建其实位置 animation1->setStartValue(QRect(this->x(),this->y(),this->width(),this->height())); animation1->setEndValue(QRect(this->x(),this->y()+10,this->width(),this->height())); //设置缓和曲线,QEasingCurve::OutBounce 为弹跳效果 animation1->setEasingCurve(QEasingCurve::OutBounce); //开始执行动画 animation1->start(); } void BounceButton::zoom2(){ //创建动画对象 QPropertyAnimation *animation1 = new QPropertyAnimation(this,"geometry"); //设置时间间隔,单位毫秒 animation1->setDuration(200); //创建其实位置 animation1->setStartValue(QRect(this->x(),this->y()+10,this->width(),this->height())); animation1->setEndValue(QRect(this->x(),this->y(),this->width(),this->height())); //设置缓和曲线,QEasingCurve::OutBounce 为弹跳效果 animation1->setEasingCurve(QEasingCurve::OutBounce); //开始执行动画 animation1->start(); } void BounceButton::setImage(QString imgPath) { m_imgPath = imgPath; QPixmap pixmap; bool ret = pixmap.load(m_imgPath); if(!ret) return; //设置图片固定尺寸 this->setFixedSize(pixmap.width(),pixmap.height()); //设置不规则图片的样式表 this->setStyleSheet("QPushButton{border:0px}"); //设置图标 this->setIcon(pixmap); //设置图标大小 this->setIconSize(QSize(pixmap.width(),pixmap.height())); }
100+评论
captcha
    类型标题大小时间
    ZIP实测通过身份证阅读器/社保卡读卡器安卓SDK,包括Java/Kotlin/Uni-app/Web等多种语言demo22.08MB9月前
    ZIPidea-jprofiler6.01MB9月前
    ZIP身份证阅读器Linux开发包gcc-linaro-5.3-2016.02-x86-64-arm-linux-gnueabihf95.83KB9月前
    ZIP身份证阅读器gcc-arm-8.3.0-2019.03-x86-64-arm-linux-gnueabihf SDK开发包96.92KB9月前
    ZIP好看的html登录界面(含源码)24.67KB9月前
    ZIP家居电商微信小程序源码762.5KB9月前
    ZIPC语言程序设计-学生管理系统设计10.22KB9月前
    ZIP最全的交换机资料.zip7.04MB9月前