BounceButtonDemo.zip
大小:26.91KB
价格:30积分
下载量:0
评分:
5.0
上传者:u012959478
更新日期:2025-09-22

QT实现弹跳按钮-自定义控件

资源文件列表(大概)

文件名
大小
BounceButtonDemo/
-
BounceButtonDemo/bouncebutton.cpp
1.92KB
BounceButtonDemo/bouncebutton.h
366B
BounceButtonDemo/BounceButtonDemo.pro
633B
BounceButtonDemo/main.cpp
172B
BounceButtonDemo/mainwindow.cpp
297B
BounceButtonDemo/mainwindow.h
217B
BounceButtonDemo/res/
-
BounceButtonDemo/res/StartButton.png
36.79KB
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()));}

用户评论 (0)

发表评论

captcha

相关资源

实测通过身份证阅读器/社保卡读卡器安卓SDK,包括Java/Kotlin/Uni-app/Web等多种语言demo

东信智能读写器SDK简介本文档描述了广东东信智能科技有限公司DONSEE系列读写器SDK的函数定义、调用方法、参数以及返回值说明,供开发人员进行二次开发时使用。SDK会自动检查是否拥有USB设备权限,如没有权限,会自动进行申请,如果您的安卓设备是定制设备,遇到找不到设备时,请询问设备定制方是否开放了USB接口的系统层权限。步骤 1:将DonseeDevice.aar拷贝到app/libs目录:步骤 2:在app/build.gradle里面添加如下代码:步骤 3:类名:import com.donsee.devices.CardReader; //读卡器设备类import com.donsee.bean.IDCardInfo; //身份证信息类import com.donsee.bean.SciCardInfo; //社保卡信息类

22.08MB26积分

idea-jprofiler

idea-jprofiler

6.01MB30积分

身份证阅读器Linux开发包gcc-linaro-5.3-2016.02-x86-64-arm-linux-gnueabihf

身份证阅读器Linux开发包gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf编译output命令:gcc donseeTest.c -o output ./libdonsee.so# arm-linux-gnueabihf-gcc -v#file libdonsee.solibdonsee.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=4cb43bd31cc828a97e94d4c3f0bc5410e3598457, with debug_info, not stripped#file outputoutput: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux

95.83KB11积分

身份证阅读器gcc-arm-8.3.0-2019.03-x86-64-arm-linux-gnueabihf SDK开发包

arm-linux-gnueabihf-gcc -vUsing built-in specs.COLLECT_GCC=arm-linux-gnueabihf-gccfile libdonsee.solibdonsee.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, with debug_info, not strippedfile outputoutput: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, with debug_info, not stripped

96.92KB33积分